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