Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 1 | import mkcwproject |
| 2 | import sys |
| 3 | import os |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 4 | import string |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 5 | |
| 6 | PROJECTDIR = os.path.join(sys.prefix, ":Mac:Build") |
| 7 | MODULEDIRS = [ # Relative to projectdirs |
| 8 | "::Modules:%s", |
| 9 | "::Modules", |
| 10 | ":::Modules", |
| 11 | ] |
| 12 | |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 13 | def relpath(base, path): |
| 14 | """Turn abs path into path relative to another. Only works for 2 abs paths |
| 15 | both pointing to folders""" |
| 16 | if not os.path.isabs(base) or not os.path.isabs(path): |
| 17 | raise 'Absolute paths only' |
| 18 | if base[-1] != ':': |
| 19 | base = base +':' |
| 20 | if path[-1] != ':': |
| 21 | path = path + ':' |
| 22 | basefields = string.split(base, os.sep) |
| 23 | pathfields = string.split(path, os.sep) |
| 24 | commonfields = len(os.path.commonprefix((basefields, pathfields))) |
| 25 | basefields = basefields[commonfields:] |
| 26 | pathfields = pathfields[commonfields:] |
| 27 | pathfields = ['']*len(basefields) + pathfields |
| 28 | return string.join(pathfields, os.sep) |
| 29 | |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 30 | def genpluginproject(module, |
| 31 | project=None, projectdir=None, |
| 32 | sources=[], sourcedirs=[], |
| 33 | libraries=[], extradirs=[], |
| 34 | extraexportsymbols=[]): |
| 35 | if not project: |
| 36 | project = module + '.mcp' |
| 37 | if not projectdir: |
| 38 | projectdir = PROJECTDIR |
| 39 | if not sources: |
| 40 | sources = [module + 'module.c'] |
| 41 | if not sourcedirs: |
| 42 | for moduledir in MODULEDIRS: |
| 43 | if '%' in moduledir: |
| 44 | moduledir = moduledir % module |
| 45 | fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) |
| 46 | if os.path.exists(fn): |
| 47 | moduledir, sourcefile = os.path.split(fn) |
| 48 | sourcedirs = [moduledir] |
| 49 | sources[0] = sourcefile |
| 50 | break |
| 51 | else: |
| 52 | print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) |
| 53 | sourcedirs = [] |
| 54 | dict = { |
| 55 | "sysprefix" : sys.prefix, |
| 56 | "sources" : sources, |
| 57 | "extrasearchdirs" : sourcedirs + extradirs, |
| 58 | "libraries": libraries, |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 59 | "mac_outputdir" : "::Plugins", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 60 | "extraexportsymbols" : extraexportsymbols, |
| 61 | } |
| 62 | mkcwproject.mkproject(os.path.join(projectdir, project), module, dict) |
| 63 | |
| 64 | def genallprojects(): |
| 65 | # Standard Python modules |
| 66 | genpluginproject("ucnhash", sources=["ucnhash.c"]) |
| 67 | genpluginproject("pyexpat", |
| 68 | sources=["pyexpat.c"], |
| 69 | libraries=["libexpat.ppc.lib"], |
Jack Jansen | 5232816 | 2000-12-29 16:07:30 +0000 | [diff] [blame] | 70 | extradirs=["::::expat:*"]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 71 | genpluginproject("zlib", |
| 72 | libraries=["zlib.ppc.Lib"], |
| 73 | extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) |
| 74 | genpluginproject("gdbm", |
| 75 | libraries=["gdbm.ppc.gusi.lib"], |
| 76 | extradirs=["::::gdbm:mac", "::::gdbm"]) |
| 77 | |
| 78 | # bgen-generated Toolbox modules |
| 79 | genpluginproject("App", libraries=["AppearanceLib"]) |
| 80 | genpluginproject("Cm", |
| 81 | libraries=["QuickTimeLib"], |
| 82 | extraexportsymbols=[ |
| 83 | "CmpObj_New", |
| 84 | "CmpObj_Convert", |
| 85 | "CmpInstObj_New", |
| 86 | "CmpInstObj_Convert", |
| 87 | ]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 88 | genpluginproject("Fm") |
| 89 | genpluginproject("Help") |
| 90 | genpluginproject("Icn", libraries=["IconServicesLib"]) |
| 91 | genpluginproject("List") |
Jack Jansen | 968c36d | 2000-12-12 21:53:48 +0000 | [diff] [blame] | 92 | genpluginproject("Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"], extradirs=["::Plugins"]) |
| 93 | genpluginproject("Qdoffs", |
| 94 | extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 95 | genpluginproject("Scrap") |
| 96 | genpluginproject("Snd", libraries=["SoundLib"]) |
| 97 | genpluginproject("Sndihooks", sources=[":snd:Sndihooks.c"]) |
| 98 | genpluginproject("TE", libraries=["DragLib"]) |
| 99 | |
| 100 | # Other Mac modules |
| 101 | genpluginproject("calldll", sources=["calldll.c"]) |
| 102 | genpluginproject("ColorPicker") |
| 103 | genpluginproject("Printing") |
| 104 | genpluginproject("waste", |
| 105 | sources=[ |
| 106 | "wastemodule.c", |
| 107 | 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', |
| 108 | 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', |
| 109 | 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', |
| 110 | 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', |
| 111 | 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', |
| 112 | 'WEObjectHandlers.c', |
| 113 | 'WETabs.c', |
| 114 | 'WETabHooks.c'], |
| 115 | libraries=['DragLib'], |
| 116 | extradirs=['::::Waste 1.3 Distribution:*'] |
| 117 | ) |
| 118 | genpluginproject("ctb") |
| 119 | genpluginproject("icglue", sources=["icgluemodule.c"], |
| 120 | libraries=["ICGlueCFM-PPC.lib"], |
| 121 | extradirs=["::::ICProgKit1.4:APIs"]) |
| 122 | genpluginproject("macspeech", libraries=["SpeechLib"]) |
| 123 | |
| 124 | if __name__ == '__main__': |
| 125 | genallprojects() |
| 126 | |