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 | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 38 | extraexportsymbols=[], outputdir=":::Lib:lib-dynload", |
| 39 | libraryflags=None, stdlibraryflags=None): |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 40 | if architecture == "all": |
| 41 | # For the time being we generate two project files. Not as nice as |
| 42 | # a single multitarget project, but easier to implement for now. |
| 43 | genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, |
Jack Jansen | 7586b04 | 2001-08-20 15:31:56 +0000 | [diff] [blame] | 44 | libraries, extradirs, extraexportsymbols, outputdir) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 45 | genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, |
Jack Jansen | 7586b04 | 2001-08-20 15:31:56 +0000 | [diff] [blame] | 46 | libraries, extradirs, extraexportsymbols, outputdir) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 47 | return |
| 48 | templatename = "template-%s" % architecture |
| 49 | targetname = "%s.%s" % (module, architecture) |
| 50 | dllname = "%s.%s.slb" % (module, architecture) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 51 | if not project: |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 52 | if architecture != "ppc": |
| 53 | project = "%s.%s.mcp"%(module, architecture) |
| 54 | else: |
| 55 | project = "%s.mcp"%module |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 56 | if not projectdir: |
| 57 | projectdir = PROJECTDIR |
| 58 | if not sources: |
| 59 | sources = [module + 'module.c'] |
| 60 | if not sourcedirs: |
| 61 | for moduledir in MODULEDIRS: |
| 62 | if '%' in moduledir: |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 63 | # For historical reasons an initial _ in the modulename |
| 64 | # is not reflected in the folder name |
| 65 | if module[0] == '_': |
| 66 | modulewithout_ = module[1:] |
| 67 | else: |
| 68 | modulewithout_ = module |
| 69 | moduledir = moduledir % modulewithout_ |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 70 | fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) |
| 71 | if os.path.exists(fn): |
| 72 | moduledir, sourcefile = os.path.split(fn) |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 73 | sourcedirs = [relpath(projectdir, moduledir)] |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 74 | sources[0] = sourcefile |
| 75 | break |
| 76 | else: |
| 77 | print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) |
| 78 | sourcedirs = [] |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 79 | if architecture == "carbon": |
| 80 | prefixname = "mwerks_carbonplugin_config.h" |
| 81 | else: |
| 82 | prefixname = "mwerks_plugin_config.h" |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 83 | dict = { |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 84 | "sysprefix" : relpath(projectdir, sys.prefix), |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 85 | "sources" : sources, |
| 86 | "extrasearchdirs" : sourcedirs + extradirs, |
| 87 | "libraries": libraries, |
Jack Jansen | d39c246 | 2001-08-19 22:29:57 +0000 | [diff] [blame] | 88 | "mac_outputdir" : outputdir, |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 89 | "extraexportsymbols" : extraexportsymbols, |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 90 | "mac_targetname" : targetname, |
| 91 | "mac_dllname" : dllname, |
| 92 | "prefixname" : prefixname, |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 93 | } |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 94 | if libraryflags: |
| 95 | dict['libraryflags'] = libraryflags |
| 96 | if stdlibraryflags: |
| 97 | dict['stdlibraryflags'] = stdlibraryflags |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 98 | mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, |
| 99 | force=FORCEREBUILD, templatename=templatename) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 100 | |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 101 | def genallprojects(force=0): |
| 102 | global FORCEREBUILD |
| 103 | FORCEREBUILD = force |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 104 | # Standard Python modules |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 105 | genpluginproject("all", "pyexpat", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 106 | sources=["pyexpat.c"], |
| 107 | libraries=["libexpat.ppc.lib"], |
Jack Jansen | 5232816 | 2000-12-29 16:07:30 +0000 | [diff] [blame] | 108 | extradirs=["::::expat:*"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 109 | genpluginproject("all", "zlib", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 110 | libraries=["zlib.ppc.Lib"], |
| 111 | extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 112 | genpluginproject("all", "gdbm", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 113 | libraries=["gdbm.ppc.gusi.lib"], |
| 114 | extradirs=["::::gdbm:mac", "::::gdbm"]) |
Jack Jansen | 6e27118 | 2001-02-12 14:50:52 +0000 | [diff] [blame] | 115 | genpluginproject("all", "_weakref", sources=["_weakref.c"]) |
| 116 | genpluginproject("all", "_symtable", sources=["symtablemodule.c"]) |
Jack Jansen | 7c10008 | 2001-08-29 22:08:06 +0000 | [diff] [blame] | 117 | # Example/test modules |
Jack Jansen | 6e27118 | 2001-02-12 14:50:52 +0000 | [diff] [blame] | 118 | genpluginproject("all", "_testcapi") |
Jack Jansen | 7c10008 | 2001-08-29 22:08:06 +0000 | [diff] [blame] | 119 | genpluginproject("all", "xx") |
| 120 | genpluginproject("all", "xxsubtype", sources=["xxsubtype.c"]) |
Jack Jansen | 6f1da00 | 2001-10-23 22:23:44 +0000 | [diff] [blame] | 121 | genpluginproject("all", "_hotshot", sources=["_hotshot.c"]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 122 | |
| 123 | # bgen-generated Toolbox modules |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 124 | genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon") |
| 125 | genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 126 | genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"], |
| 127 | libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 128 | genpluginproject("carbon", "_App", outputdir="::Lib:Carbon") |
| 129 | genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") |
| 130 | genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon") |
Just van Rossum | 11ccf3c | 2001-12-13 13:21:38 +0000 | [diff] [blame] | 131 | # XXX can't work properly because we need to set a custom fragment initializer |
| 132 | #genpluginproject("carbon", "_CG", |
| 133 | # sources=["_CGModule.c", "CFMLateImport.c"], |
| 134 | # libraries=["CGStubLib"], |
| 135 | # outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 136 | genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 137 | genpluginproject("ppc", "_Ctl", libraries=["CarbonAccessors.o", "ControlsLib", "AppearanceLib"], |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 138 | libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 139 | genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 140 | genpluginproject("ppc", "_Dlg", libraries=["CarbonAccessors.o", "DialogsLib", "AppearanceLib"], |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 141 | libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 142 | genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon") |
| 143 | genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon") |
| 144 | genpluginproject("all", "_Evt", outputdir="::Lib:Carbon") |
| 145 | genpluginproject("all", "_Fm", outputdir="::Lib:Carbon") |
| 146 | genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon") |
| 147 | genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon") |
| 148 | genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon") |
| 149 | genpluginproject("all", "_List", outputdir="::Lib:Carbon") |
| 150 | genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 151 | genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"], |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 152 | libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 153 | genpluginproject("all", "_Qd", outputdir="::Lib:Carbon") |
| 154 | genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon") |
| 155 | genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon") |
| 156 | genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon") |
| 157 | genpluginproject("all", "_Res", outputdir="::Lib:Carbon") |
| 158 | genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 159 | genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 160 | genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon") |
| 161 | genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon") |
Jack Jansen | a7594db | 2001-12-05 22:46:23 +0000 | [diff] [blame] | 162 | genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], outputdir="::Lib:Carbon") |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 163 | genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon") |
| 164 | genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon") |
| 165 | genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon") |
| 166 | genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon") |
Jack Jansen | b3be216 | 2001-11-30 14:16:36 +0000 | [diff] [blame] | 167 | genpluginproject("ppc", "_Win", libraries=["CarbonAccessors.o", "WindowsLib", "AppearanceLib"], |
| 168 | libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") |
Jack Jansen | 1986412 | 2001-07-13 20:57:47 +0000 | [diff] [blame] | 169 | # Carbon Only? |
Jack Jansen | 77105a9 | 2001-08-23 13:51:46 +0000 | [diff] [blame] | 170 | genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon") |
Just van Rossum | aa6e83f | 2001-12-12 22:42:37 +0000 | [diff] [blame] | 171 | genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon") |
Jack Jansen | df222d2 | 2001-11-06 15:56:56 +0000 | [diff] [blame] | 172 | genpluginproject("carbon", "hfsplus") |
Jack Jansen | f4b9fb7 | 2001-06-26 21:52:08 +0000 | [diff] [blame] | 173 | |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 174 | # Other Mac modules |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 175 | genpluginproject("all", "calldll", sources=["calldll.c"]) |
| 176 | genpluginproject("all", "ColorPicker") |
| 177 | genpluginproject("ppc", "Printing") |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 178 | ## genpluginproject("ppc", "waste", |
| 179 | ## sources=[ |
| 180 | ## "wastemodule.c", |
| 181 | ## 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', |
| 182 | ## 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', |
| 183 | ## 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', |
| 184 | ## 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', |
| 185 | ## 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', |
| 186 | ## 'WEObjectHandlers.c', |
| 187 | ## 'WETabs.c', |
| 188 | ## 'WETabHooks.c'], |
| 189 | ## libraries=['DragLib'], |
| 190 | ## extradirs=[ |
| 191 | ## '::::Waste 1.3 Distribution:*', |
| 192 | ## '::::ICProgKit1.4:APIs'] |
| 193 | ## ) |
| 194 | # This is a hack, combining parts of Waste 2.0 with parts of 1.3 |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 195 | genpluginproject("ppc", "waste", |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 196 | sources=[ |
| 197 | "wastemodule.c", |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 198 | "WEObjectHandlers.c", |
| 199 | "WETabs.c", "WETabHooks.c"], |
| 200 | libraries=[ |
| 201 | "WASTE.PPC.lib", |
| 202 | "TextCommon", |
| 203 | "UnicodeConverter", |
| 204 | "DragLib", |
| 205 | ], |
Jack Jansen | 0e1c24a | 2001-01-22 14:50:05 +0000 | [diff] [blame] | 206 | extradirs=[ |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 207 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', |
| 208 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', |
| 209 | '::wastemods', |
| 210 | ] |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 211 | ) |
Jack Jansen | 8c98266 | 2001-01-24 16:02:07 +0000 | [diff] [blame] | 212 | genpluginproject("carbon", "waste", |
| 213 | sources=[ |
| 214 | "wastemodule.c", |
| 215 | "WEObjectHandlers.c", |
| 216 | "WETabs.c", "WETabHooks.c"], |
| 217 | libraries=["WASTE.Carbon.lib"], |
| 218 | extradirs=[ |
| 219 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', |
| 220 | '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 221 | '::wastemods', |
| 222 | ] |
Jack Jansen | 8c98266 | 2001-01-24 16:02:07 +0000 | [diff] [blame] | 223 | ) |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 224 | ## '::::Waste 1.3 Distribution:Extras:Sample Object Handlers', |
| 225 | ## '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2'] |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 226 | genpluginproject("ppc", "ctb") |
| 227 | genpluginproject("ppc", "icglue", sources=["icgluemodule.c"], |
Jack Jansen | 4a667c7 | 2002-01-11 12:39:03 +0000 | [diff] [blame^] | 228 | libraries=["InternetConfigLib"]) |
| 229 | genpluginproject("carbon", "icglue", sources=["icgluemodule.c"]) |
Jack Jansen | 8c19b88 | 2001-01-23 22:36:26 +0000 | [diff] [blame] | 230 | genpluginproject("ppc", "macspeech", libraries=["SpeechLib"]) |
Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 231 | |
| 232 | if __name__ == '__main__': |
| 233 | genallprojects() |
| 234 | |
Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 235 | |