blob: be3311358d4065976d2317b3bc54aabfd9a9d57f [file] [log] [blame]
Jack Jansen6c502d72000-12-03 22:31:50 +00001import mkcwproject
2import sys
3import os
Jack Jansenb55b7bb2001-01-03 16:44:56 +00004import string
Jack Jansen6c502d72000-12-03 22:31:50 +00005
Jack Jansene791a642001-08-16 20:39:17 +00006PYTHONDIR = sys.prefix
7PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build")
Jack Jansen6c502d72000-12-03 22:31:50 +00008MODULEDIRS = [ # Relative to projectdirs
9 "::Modules:%s",
10 "::Modules",
11 ":::Modules",
12]
13
Jack Jansen1eda2032001-01-21 22:24:27 +000014# Global variable to control forced rebuild (otherwise the project is only rebuilt
15# when it is changed)
16FORCEREBUILD=0
17
Jack Jansenb55b7bb2001-01-03 16:44:56 +000018def 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 Jansen1eda2032001-01-21 22:24:27 +000023 if base[-1] == ':':
24 base = base[:-1]
Jack Jansenb55b7bb2001-01-03 16:44:56 +000025 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 Jansen1eda2032001-01-21 22:24:27 +000030 pathfields = ['']*(len(basefields)+1) + pathfields
31 rv = string.join(pathfields, os.sep)
32 return rv
Jack Jansenb55b7bb2001-01-03 16:44:56 +000033
Jack Jansen8c19b882001-01-23 22:36:26 +000034def genpluginproject(architecture, module,
Jack Jansen6c502d72000-12-03 22:31:50 +000035 project=None, projectdir=None,
36 sources=[], sourcedirs=[],
37 libraries=[], extradirs=[],
Jack Jansend39c2462001-08-19 22:29:57 +000038 extraexportsymbols=[], outputdir=":::Lib:lib-dynload"):
Jack Jansen8c19b882001-01-23 22:36:26 +000039 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,
43 libraries, extradirs, extraexportsymbols)
44 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
45 libraries, extradirs, extraexportsymbols)
46 return
47 templatename = "template-%s" % architecture
48 targetname = "%s.%s" % (module, architecture)
49 dllname = "%s.%s.slb" % (module, architecture)
Jack Jansen6c502d72000-12-03 22:31:50 +000050 if not project:
Jack Jansen8c19b882001-01-23 22:36:26 +000051 if architecture != "ppc":
52 project = "%s.%s.mcp"%(module, architecture)
53 else:
54 project = "%s.mcp"%module
Jack Jansen6c502d72000-12-03 22:31:50 +000055 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:
62 moduledir = moduledir % module
63 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
64 if os.path.exists(fn):
65 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000066 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000067 sources[0] = sourcefile
68 break
69 else:
70 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
71 sourcedirs = []
Jack Jansen8c19b882001-01-23 22:36:26 +000072 if architecture == "carbon":
73 prefixname = "mwerks_carbonplugin_config.h"
74 else:
75 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000076 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000077 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000078 "sources" : sources,
79 "extrasearchdirs" : sourcedirs + extradirs,
80 "libraries": libraries,
Jack Jansend39c2462001-08-19 22:29:57 +000081 "mac_outputdir" : outputdir,
Jack Jansen6c502d72000-12-03 22:31:50 +000082 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000083 "mac_targetname" : targetname,
84 "mac_dllname" : dllname,
85 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000086 }
Jack Jansen8c19b882001-01-23 22:36:26 +000087 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
88 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +000089
Jack Jansen1eda2032001-01-21 22:24:27 +000090def genallprojects(force=0):
91 global FORCEREBUILD
92 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +000093 # Standard Python modules
Jack Jansen8c19b882001-01-23 22:36:26 +000094 genpluginproject("all", "pyexpat",
Jack Jansen6c502d72000-12-03 22:31:50 +000095 sources=["pyexpat.c"],
96 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +000097 extradirs=["::::expat:*"])
Jack Jansen8c19b882001-01-23 22:36:26 +000098 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +000099 libraries=["zlib.ppc.Lib"],
100 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000101 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000102 libraries=["gdbm.ppc.gusi.lib"],
103 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000104 genpluginproject("all", "_weakref", sources=["_weakref.c"])
105 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
106 genpluginproject("all", "_testcapi")
Jack Jansen6c502d72000-12-03 22:31:50 +0000107
108 # bgen-generated Toolbox modules
Jack Jansend39c2462001-08-19 22:29:57 +0000109 genpluginproject("carbon", "AE", outputdir="::Lib:Carbon")
110 genpluginproject("ppc", "AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon")
111 genpluginproject("ppc", "App", libraries=["AppearanceLib"], outputdir="::Lib:Carbon")
112 genpluginproject("carbon", "App", outputdir="::Lib:Carbon")
113 genpluginproject("ppc", "Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
114 genpluginproject("carbon", "Cm", outputdir="::Lib:Carbon")
115 genpluginproject("carbon", "Ctl", outputdir="::Lib:Carbon")
116 genpluginproject("ppc", "Ctl", libraries=["ControlsLib", "AppearanceLib"],
117 outputdir="::Lib:Carbon")
118 genpluginproject("carbon", "Dlg", outputdir="::Lib:Carbon")
119 genpluginproject("ppc", "Dlg", libraries=["DialogsLib", "AppearanceLib"],
120 outputdir="::Lib:Carbon")
121 genpluginproject("carbon", "Drag", outputdir="::Lib:Carbon")
122 genpluginproject("ppc", "Drag", libraries=["DragLib"], outputdir="::Lib:Carbon")
123 genpluginproject("all", "Evt", outputdir="::Lib:Carbon")
124 genpluginproject("all", "Fm", outputdir="::Lib:Carbon")
125 genpluginproject("ppc", "Help", outputdir="::Lib:Carbon")
Jack Jansen8c19b882001-01-23 22:36:26 +0000126 genpluginproject("ppc", "Icn", libraries=["IconServicesLib"])
Jack Jansend39c2462001-08-19 22:29:57 +0000127 genpluginproject("carbon", "Icn", outputdir="::Lib:Carbon")
128 genpluginproject("all", "List", outputdir="::Lib:Carbon")
129 genpluginproject("carbon", "Menu", outputdir="::Lib:Carbon")
130 genpluginproject("ppc", "Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"],
131 outputdir="::Lib:Carbon")
132 genpluginproject("all", "Qd", outputdir="::Lib:Carbon")
133 genpluginproject("ppc", "Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
134 genpluginproject("carbon", "Qt", outputdir="::Lib:Carbon")
135 genpluginproject("all", "Qdoffs", outputdir="::Lib:Carbon")
136 genpluginproject("all", "Res", outputdir="::Lib:Carbon")
137 genpluginproject("all", "Scrap", outputdir="::Lib:Carbon")
138 genpluginproject("ppc", "Snd", libraries=["SoundLib"], outputdir="::Lib:Carbon")
139 genpluginproject("carbon", "Snd", outputdir="::Lib:Carbon")
140 genpluginproject("all", "Sndihooks", sources=[":snd:Sndihooks.c"], outputdir="::Lib:Carbon")
141 genpluginproject("ppc", "TE", libraries=["DragLib"], outputdir="::Lib:Carbon")
142 genpluginproject("carbon", "TE", outputdir="::Lib:Carbon")
143 genpluginproject("ppc", "Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
144 genpluginproject("carbon", "Mlte", outputdir="::Lib:Carbon")
145 genpluginproject("carbon", "Win", outputdir="::Lib:Carbon")
146 genpluginproject("ppc", "Win", libraries=["WindowsLib", "AppearanceLib"],
147 outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000148 # Carbon Only?
Jack Jansend39c2462001-08-19 22:29:57 +0000149 genpluginproject("carbon", "CF", outputdir="::Lib:Carbon")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000150
Jack Jansen6c502d72000-12-03 22:31:50 +0000151 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000152 genpluginproject("all", "calldll", sources=["calldll.c"])
153 genpluginproject("all", "ColorPicker")
154 genpluginproject("ppc", "Printing")
155 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000156 sources=[
157 "wastemodule.c",
158 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
159 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
160 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
161 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
162 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
163 'WEObjectHandlers.c',
164 'WETabs.c',
165 'WETabHooks.c'],
166 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000167 extradirs=[
168 '::::Waste 1.3 Distribution:*',
169 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000170 )
Jack Jansen8c982662001-01-24 16:02:07 +0000171 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
172 genpluginproject("carbon", "waste",
173 sources=[
174 "wastemodule.c",
175 "WEObjectHandlers.c",
176 "WETabs.c", "WETabHooks.c"],
177 libraries=["WASTE.Carbon.lib"],
178 extradirs=[
179 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
180 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
181 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
182 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
183 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000184 genpluginproject("ppc", "ctb")
185 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000186 libraries=["ICGlueCFM-PPC.lib"],
187 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000188 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
189 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000190 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000191
192if __name__ == '__main__':
193 genallprojects()
194
Jack Jansen1eda2032001-01-21 22:24:27 +0000195