blob: 1286993b0f91e26f59a9550eb21e0130a18804b8 [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 Jansenb3be2162001-11-30 14:16:36 +000038 extraexportsymbols=[], outputdir=":::Lib:lib-dynload",
Jack Jansen86c4d642002-03-14 23:14:43 +000039 libraryflags=None, stdlibraryflags=None, prefixname=None):
Jack Jansen8c19b882001-01-23 22:36:26 +000040 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 Jansen9051e0e2002-03-22 14:15:07 +000044 libraries, extradirs, extraexportsymbols, outputdir, libraryflags,
45 stdlibraryflags, prefixname)
Jack Jansen8c19b882001-01-23 22:36:26 +000046 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
Jack Jansen9051e0e2002-03-22 14:15:07 +000047 libraries, extradirs, extraexportsymbols, outputdir, libraryflags,
48 stdlibraryflags, prefixname)
Jack Jansen8c19b882001-01-23 22:36:26 +000049 return
50 templatename = "template-%s" % architecture
51 targetname = "%s.%s" % (module, architecture)
52 dllname = "%s.%s.slb" % (module, architecture)
Jack Jansen6c502d72000-12-03 22:31:50 +000053 if not project:
Jack Jansen8c19b882001-01-23 22:36:26 +000054 if architecture != "ppc":
55 project = "%s.%s.mcp"%(module, architecture)
56 else:
57 project = "%s.mcp"%module
Jack Jansen6c502d72000-12-03 22:31:50 +000058 if not projectdir:
59 projectdir = PROJECTDIR
60 if not sources:
61 sources = [module + 'module.c']
62 if not sourcedirs:
63 for moduledir in MODULEDIRS:
64 if '%' in moduledir:
Jack Jansen77105a92001-08-23 13:51:46 +000065 # For historical reasons an initial _ in the modulename
66 # is not reflected in the folder name
67 if module[0] == '_':
68 modulewithout_ = module[1:]
69 else:
70 modulewithout_ = module
71 moduledir = moduledir % modulewithout_
Jack Jansen6c502d72000-12-03 22:31:50 +000072 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
73 if os.path.exists(fn):
74 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000075 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000076 sources[0] = sourcefile
77 break
78 else:
79 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
80 sourcedirs = []
Jack Jansen86c4d642002-03-14 23:14:43 +000081 if prefixname:
82 pass
83 elif architecture == "carbon":
Jack Jansen8c19b882001-01-23 22:36:26 +000084 prefixname = "mwerks_carbonplugin_config.h"
85 else:
86 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000087 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000088 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000089 "sources" : sources,
90 "extrasearchdirs" : sourcedirs + extradirs,
91 "libraries": libraries,
Jack Jansend39c2462001-08-19 22:29:57 +000092 "mac_outputdir" : outputdir,
Jack Jansen6c502d72000-12-03 22:31:50 +000093 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000094 "mac_targetname" : targetname,
95 "mac_dllname" : dllname,
96 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000097 }
Jack Jansenb3be2162001-11-30 14:16:36 +000098 if libraryflags:
99 dict['libraryflags'] = libraryflags
100 if stdlibraryflags:
101 dict['stdlibraryflags'] = stdlibraryflags
Jack Jansen8c19b882001-01-23 22:36:26 +0000102 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
103 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +0000104
Jack Jansen1eda2032001-01-21 22:24:27 +0000105def genallprojects(force=0):
106 global FORCEREBUILD
107 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +0000108 # Standard Python modules
Jack Jansen86c4d642002-03-14 23:14:43 +0000109 genpluginproject("ppc", "pyexpat",
110 sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"],
111 extradirs=[":::Modules:expat"],
112 prefixname="mwerks_pyexpat_config.h"
113 )
114 genpluginproject("carbon", "pyexpat",
115 sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"],
116 extradirs=[":::Modules:expat"],
117 prefixname="mwerks_carbonpyexpat_config.h"
118 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000119 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +0000120 libraries=["zlib.ppc.Lib"],
121 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000122 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000123 libraries=["gdbm.ppc.gusi.lib"],
124 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000125 genpluginproject("all", "_weakref", sources=["_weakref.c"])
126 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
Jack Jansen7c100082001-08-29 22:08:06 +0000127 # Example/test modules
Jack Jansen6e271182001-02-12 14:50:52 +0000128 genpluginproject("all", "_testcapi")
Jack Jansen7c100082001-08-29 22:08:06 +0000129 genpluginproject("all", "xx")
130 genpluginproject("all", "xxsubtype", sources=["xxsubtype.c"])
Jack Jansen6f1da002001-10-23 22:23:44 +0000131 genpluginproject("all", "_hotshot", sources=["_hotshot.c"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000132
133 # bgen-generated Toolbox modules
Jack Jansen77105a92001-08-23 13:51:46 +0000134 genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000135 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"],
136 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000137 genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"],
138 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000139 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000140 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"],
141 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000142 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
Just van Rossum11ccf3c2001-12-13 13:21:38 +0000143 # XXX can't work properly because we need to set a custom fragment initializer
144 #genpluginproject("carbon", "_CG",
145 # sources=["_CGModule.c", "CFMLateImport.c"],
146 # libraries=["CGStubLib"],
147 # outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000148 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000149 genpluginproject("ppc", "_Ctl", libraries=["CarbonAccessors.o", "ControlsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000150 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000151 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000152 genpluginproject("ppc", "_Dlg", libraries=["CarbonAccessors.o", "DialogsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000153 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000154 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000155 genpluginproject("ppc", "_Drag", libraries=["DragLib"],
156 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
157 genpluginproject("all", "_Evt",
158 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
159 genpluginproject("all", "_Fm",
160 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000161 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000162 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"],
163 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000164 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
165 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
166 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000167 genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000168 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000169 genpluginproject("all", "_Qd",
170 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
171 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"],
172 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
173 genpluginproject("carbon", "_Qt",
174 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
175 genpluginproject("all", "_Qdoffs",
176 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen9051e0e2002-03-22 14:15:07 +0000177 genpluginproject("all", "_Res",
178 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000179 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000180 genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000181 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
182 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000183 genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"],
184 stdlibraryflags="Debug, WeakImport",
185 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000186 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000187 genpluginproject("ppc", "_Mlte", libraries=["Textension"],
188 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000189 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
190 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
Jack Jansenb3be2162001-11-30 14:16:36 +0000191 genpluginproject("ppc", "_Win", libraries=["CarbonAccessors.o", "WindowsLib", "AppearanceLib"],
192 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000193 # Carbon Only?
Jack Jansen77105a92001-08-23 13:51:46 +0000194 genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon")
Just van Rossumaa6e83f2001-12-12 22:42:37 +0000195 genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon")
Jack Jansendf222d22001-11-06 15:56:56 +0000196 genpluginproject("carbon", "hfsplus")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000197
Jack Jansen6c502d72000-12-03 22:31:50 +0000198 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000199 genpluginproject("all", "calldll", sources=["calldll.c"])
200 genpluginproject("all", "ColorPicker")
201 genpluginproject("ppc", "Printing")
Jack Jansen4a667c72002-01-11 12:39:03 +0000202## genpluginproject("ppc", "waste",
203## sources=[
204## "wastemodule.c",
205## 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
206## 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
207## 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
208## 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
209## 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
210## 'WEObjectHandlers.c',
211## 'WETabs.c',
212## 'WETabHooks.c'],
213## libraries=['DragLib'],
214## extradirs=[
215## '::::Waste 1.3 Distribution:*',
216## '::::ICProgKit1.4:APIs']
217## )
218 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
Jack Jansen8c19b882001-01-23 22:36:26 +0000219 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000220 sources=[
221 "wastemodule.c",
Jack Jansen4a667c72002-01-11 12:39:03 +0000222 "WEObjectHandlers.c",
223 "WETabs.c", "WETabHooks.c"],
224 libraries=[
225 "WASTE.PPC.lib",
226 "TextCommon",
227 "UnicodeConverter",
228 "DragLib",
229 ],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000230 extradirs=[
Jack Jansen4a667c72002-01-11 12:39:03 +0000231 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
232 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
233 '::wastemods',
234 ]
Jack Jansen6c502d72000-12-03 22:31:50 +0000235 )
Jack Jansen8c982662001-01-24 16:02:07 +0000236 genpluginproject("carbon", "waste",
237 sources=[
238 "wastemodule.c",
239 "WEObjectHandlers.c",
240 "WETabs.c", "WETabHooks.c"],
241 libraries=["WASTE.Carbon.lib"],
242 extradirs=[
243 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
244 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
Jack Jansen4a667c72002-01-11 12:39:03 +0000245 '::wastemods',
246 ]
Jack Jansen8c982662001-01-24 16:02:07 +0000247 )
Jack Jansen4a667c72002-01-11 12:39:03 +0000248## '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
249## '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
Jack Jansen8c19b882001-01-23 22:36:26 +0000250 genpluginproject("ppc", "ctb")
251 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen4a667c72002-01-11 12:39:03 +0000252 libraries=["InternetConfigLib"])
253 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000254 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000255
256if __name__ == '__main__':
257 genallprojects()
258
Jack Jansen1eda2032001-01-21 22:24:27 +0000259