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 | |
Jack Jansen | e791a64 | 2001-08-16 20:39:17 +0000 | [diff] [blame] | 6 | PYTHONDIR = sys.prefix |
| 7 | PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build") |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 8 | MODULEDIRS = [ # Relative to projectdirs |
| 9 | "::Modules:%s", |
| 10 | "::Modules", |
| 11 | ":::Modules", |
| 12 | ] |
| 13 | |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 14 | # Global variable to control forced rebuild (otherwise the project is only rebuilt |
| 15 | # when it is changed) |
| 16 | FORCEREBUILD=0 |
| 17 | |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 18 | def relpath(base, path): |
| 19 | """Turn abs path into path relative to another. Only works for 2 abs paths |
| 20 | both pointing to folders""" |
| 21 | if not os.path.isabs(base) or not os.path.isabs(path): |
| 22 | raise 'Absolute paths only' |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 23 | if base[-1] == ':': |
| 24 | base = base[:-1] |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 25 | basefields = string.split(base, os.sep) |
| 26 | pathfields = string.split(path, os.sep) |
| 27 | commonfields = len(os.path.commonprefix((basefields, pathfields))) |
| 28 | basefields = basefields[commonfields:] |
| 29 | pathfields = pathfields[commonfields:] |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 30 | pathfields = ['']*(len(basefields)+1) + pathfields |
| 31 | rv = string.join(pathfields, os.sep) |
| 32 | return rv |
Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 33 | |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 34 | def genpluginproject(architecture, module, |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 35 | project=None, projectdir=None, |
| 36 | sources=[], sourcedirs=[], |
| 37 | libraries=[], extradirs=[], |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 38 | extraexportsymbols=[], outputdir=":::Lib:lib-dynload"): |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 39 | if architecture == "all": |
| 40 | # For the time being we generate two project files. Not as nice as |
| 41 | # a single multitarget project, but easier to implement for now. |
| 42 | genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, |
Jack Jansen | 7586b04 | 2001-08-20 15:31:56 +0000 | [diff] [blame] | 43 | libraries, extradirs, extraexportsymbols, outputdir) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 44 | genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, |
Jack Jansen | 7586b04 | 2001-08-20 15:31:56 +0000 | [diff] [blame] | 45 | libraries, extradirs, extraexportsymbols, outputdir) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 46 | return |
| 47 | templatename = "template-%s" % architecture |
| 48 | targetname = "%s.%s" % (module, architecture) |
| 49 | dllname = "%s.%s.slb" % (module, architecture) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 50 | if not project: |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 51 | if architecture != "ppc": |
| 52 | project = "%s.%s.mcp"%(module, architecture) |
| 53 | else: |
| 54 | project = "%s.mcp"%module |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 55 | if not projectdir: |
| 56 | projectdir = PROJECTDIR |
| 57 | if not sources: |
| 58 | sources = [module + 'module.c'] |
| 59 | if not sourcedirs: |
| 60 | for moduledir in MODULEDIRS: |
| 61 | if '%' in moduledir: |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 62 | # For historical reasons an initial _ in the modulename |
| 63 | # is not reflected in the folder name |
| 64 | if module[0] == '_': |
| 65 | modulewithout_ = module[1:] |
| 66 | else: |
| 67 | modulewithout_ = module |
| 68 | moduledir = moduledir % modulewithout_ |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 69 | fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) |
| 70 | if os.path.exists(fn): |
| 71 | moduledir, sourcefile = os.path.split(fn) |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 72 | sourcedirs = [relpath(projectdir, moduledir)] |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 73 | sources[0] = sourcefile |
| 74 | break |
| 75 | else: |
| 76 | print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) |
| 77 | sourcedirs = [] |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 78 | if architecture == "carbon": |
| 79 | prefixname = "mwerks_carbonplugin_config.h" |
| 80 | else: |
| 81 | prefixname = "mwerks_plugin_config.h" |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 82 | dict = { |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 83 | "sysprefix" : relpath(projectdir, sys.prefix), |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 84 | "sources" : sources, |
| 85 | "extrasearchdirs" : sourcedirs + extradirs, |
| 86 | "libraries": libraries, |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 87 | "mac_outputdir" : outputdir, |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 88 | "extraexportsymbols" : extraexportsymbols, |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 89 | "mac_targetname" : targetname, |
| 90 | "mac_dllname" : dllname, |
| 91 | "prefixname" : prefixname, |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 92 | } |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 93 | mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, |
| 94 | force=FORCEREBUILD, templatename=templatename) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 95 | |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 96 | def genallprojects(force=0): |
| 97 | global FORCEREBUILD |
| 98 | FORCEREBUILD = force |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 99 | # Standard Python modules |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 100 | genpluginproject("all", "pyexpat", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 101 | sources=["pyexpat.c"], |
| 102 | libraries=["libexpat.ppc.lib"], |
Jack Jansen | 5232816 | 2000-12-29 16:07:30 +0000 | [diff] [blame] | 103 | extradirs=["::::expat:*"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 104 | genpluginproject("all", "zlib", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 105 | libraries=["zlib.ppc.Lib"], |
| 106 | extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 107 | genpluginproject("all", "gdbm", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 108 | libraries=["gdbm.ppc.gusi.lib"], |
| 109 | extradirs=["::::gdbm:mac", "::::gdbm"]) |
Jack Jansen | 6e27118 | 2001-02-12 14:50:52 +0000 | [diff] [blame] | 110 | genpluginproject("all", "_weakref", sources=["_weakref.c"]) |
| 111 | genpluginproject("all", "_symtable", sources=["symtablemodule.c"]) |
| 112 | genpluginproject("all", "_testcapi") |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 113 | |
| 114 | # bgen-generated Toolbox modules |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 115 | genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") |
| 116 | genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon") |
| 117 | genpluginproject("ppc", "_App", libraries=["AppearanceLib"], outputdir="::Lib:Carbon") |
| 118 | genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") |
| 119 | genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") |
| 120 | genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") |
| 121 | genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon") |
| 122 | genpluginproject("ppc", "_Ctl", libraries=["ControlsLib", "AppearanceLib"], |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 123 | outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 124 | genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon") |
| 125 | genpluginproject("ppc", "_Dlg", libraries=["DialogsLib", "AppearanceLib"], |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 126 | outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 127 | genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") |
| 128 | genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon") |
| 129 | genpluginproject("all", "_Evt", outputdir="::Lib:Carbon") |
| 130 | genpluginproject("all", "_Fm", outputdir="::Lib:Carbon") |
| 131 | genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") |
| 132 | genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon") |
| 133 | genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") |
| 134 | genpluginproject("all", "_List", outputdir="::Lib:Carbon") |
| 135 | genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon") |
| 136 | genpluginproject("ppc", "_Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"], |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 137 | outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 138 | genpluginproject("all", "_Qd", outputdir="::Lib:Carbon") |
| 139 | genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") |
| 140 | genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") |
| 141 | genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") |
| 142 | genpluginproject("all", "_Res", outputdir="::Lib:Carbon") |
| 143 | genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") |
| 144 | genpluginproject("ppc", "_Snd", libraries=["SoundLib"], outputdir="::Lib:Carbon") |
| 145 | genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") |
| 146 | genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") |
| 147 | genpluginproject("ppc", "_TE", libraries=["DragLib"], outputdir="::Lib:Carbon") |
| 148 | genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") |
| 149 | genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon") |
| 150 | genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") |
| 151 | genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") |
| 152 | genpluginproject("ppc", "_Win", libraries=["WindowsLib", "AppearanceLib"], |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 153 | outputdir="::Lib:Carbon") |
Jack Jansen | 1986412 | 2001-07-13 20:57:47 +0000 | [diff] [blame] | 154 | # Carbon Only? |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 155 | genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon") |
Jack Jansen | f4b9fb7 | 2001-06-26 21:52:08 +0000 | [diff] [blame] | 156 | |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 157 | # Other Mac modules |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 158 | genpluginproject("all", "calldll", sources=["calldll.c"]) |
| 159 | genpluginproject("all", "ColorPicker") |
| 160 | genpluginproject("ppc", "Printing") |
| 161 | genpluginproject("ppc", "waste", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 162 | sources=[ |
| 163 | "wastemodule.c", |
| 164 | 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', |
| 165 | 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', |
| 166 | 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', |
| 167 | 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', |
| 168 | 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', |
| 169 | 'WEObjectHandlers.c', |
| 170 | 'WETabs.c', |
| 171 | 'WETabHooks.c'], |
| 172 | libraries=['DragLib'], |
Jack Jansen | 0e1c24a | 2001-01-22 14:50:05 +0000 | [diff] [blame] | 173 | extradirs=[ |
| 174 | '::::Waste 1.3 Distribution:*', |
| 175 | '::::ICProgKit1.4:APIs'] |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 176 | ) |
Jack Jansen | 8c98266 | 2001-01-24 16:02:07 +0000 | [diff] [blame] | 177 | # This is a hack, combining parts of Waste 2.0 with parts of 1.3 |
| 178 | genpluginproject("carbon", "waste", |
| 179 | sources=[ |
| 180 | "wastemodule.c", |
| 181 | "WEObjectHandlers.c", |
| 182 | "WETabs.c", "WETabHooks.c"], |
| 183 | libraries=["WASTE.Carbon.lib"], |
| 184 | extradirs=[ |
| 185 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', |
| 186 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', |
| 187 | '::::Waste 1.3 Distribution:Extras:Sample Object Handlers', |
| 188 | '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2'] |
| 189 | ) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 190 | genpluginproject("ppc", "ctb") |
| 191 | genpluginproject("ppc", "icglue", sources=["icgluemodule.c"], |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 192 | libraries=["ICGlueCFM-PPC.lib"], |
| 193 | extradirs=["::::ICProgKit1.4:APIs"]) |
Jack Jansen | 5a8115c | 2001-01-29 13:27:46 +0000 | [diff] [blame] | 194 | genpluginproject("carbon", "icglue", sources=["icgluemodule.c"], |
| 195 | extradirs=["::::ICProgKit1.4:APIs"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 196 | genpluginproject("ppc", "macspeech", libraries=["SpeechLib"]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 197 | |
| 198 | if __name__ == '__main__': |
| 199 | genallprojects() |
| 200 | |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 201 | |