blob: d95c4adb7f745d2997b4f9383103f7751c64ccf7 [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")
135 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000136 genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"],
137 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000138 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
139 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
140 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
Just van Rossum11ccf3c2001-12-13 13:21:38 +0000141 # XXX can't work properly because we need to set a custom fragment initializer
142 #genpluginproject("carbon", "_CG",
143 # sources=["_CGModule.c", "CFMLateImport.c"],
144 # libraries=["CGStubLib"],
145 # outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000146 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000147 genpluginproject("ppc", "_Ctl", libraries=["CarbonAccessors.o", "ControlsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000148 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000149 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000150 genpluginproject("ppc", "_Dlg", libraries=["CarbonAccessors.o", "DialogsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000151 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000152 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
153 genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon")
154 genpluginproject("all", "_Evt", outputdir="::Lib:Carbon")
155 genpluginproject("all", "_Fm", outputdir="::Lib:Carbon")
156 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
157 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon")
158 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
159 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
160 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000161 genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000162 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000163 genpluginproject("all", "_Qd", outputdir="::Lib:Carbon")
164 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
165 genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon")
166 genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon")
Jack Jansen9051e0e2002-03-22 14:15:07 +0000167 genpluginproject("all", "_Res",
168 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000169 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000170 genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000171 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
172 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000173 genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"], outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000174 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
175 genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
176 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
177 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
Jack Jansenb3be2162001-11-30 14:16:36 +0000178 genpluginproject("ppc", "_Win", libraries=["CarbonAccessors.o", "WindowsLib", "AppearanceLib"],
179 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000180 # Carbon Only?
Jack Jansen77105a92001-08-23 13:51:46 +0000181 genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon")
Just van Rossumaa6e83f2001-12-12 22:42:37 +0000182 genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon")
Jack Jansendf222d22001-11-06 15:56:56 +0000183 genpluginproject("carbon", "hfsplus")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000184
Jack Jansen6c502d72000-12-03 22:31:50 +0000185 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000186 genpluginproject("all", "calldll", sources=["calldll.c"])
187 genpluginproject("all", "ColorPicker")
188 genpluginproject("ppc", "Printing")
Jack Jansen4a667c72002-01-11 12:39:03 +0000189## genpluginproject("ppc", "waste",
190## sources=[
191## "wastemodule.c",
192## 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
193## 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
194## 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
195## 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
196## 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
197## 'WEObjectHandlers.c',
198## 'WETabs.c',
199## 'WETabHooks.c'],
200## libraries=['DragLib'],
201## extradirs=[
202## '::::Waste 1.3 Distribution:*',
203## '::::ICProgKit1.4:APIs']
204## )
205 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
Jack Jansen8c19b882001-01-23 22:36:26 +0000206 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000207 sources=[
208 "wastemodule.c",
Jack Jansen4a667c72002-01-11 12:39:03 +0000209 "WEObjectHandlers.c",
210 "WETabs.c", "WETabHooks.c"],
211 libraries=[
212 "WASTE.PPC.lib",
213 "TextCommon",
214 "UnicodeConverter",
215 "DragLib",
216 ],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000217 extradirs=[
Jack Jansen4a667c72002-01-11 12:39:03 +0000218 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
219 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
220 '::wastemods',
221 ]
Jack Jansen6c502d72000-12-03 22:31:50 +0000222 )
Jack Jansen8c982662001-01-24 16:02:07 +0000223 genpluginproject("carbon", "waste",
224 sources=[
225 "wastemodule.c",
226 "WEObjectHandlers.c",
227 "WETabs.c", "WETabHooks.c"],
228 libraries=["WASTE.Carbon.lib"],
229 extradirs=[
230 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
231 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
Jack Jansen4a667c72002-01-11 12:39:03 +0000232 '::wastemods',
233 ]
Jack Jansen8c982662001-01-24 16:02:07 +0000234 )
Jack Jansen4a667c72002-01-11 12:39:03 +0000235## '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
236## '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
Jack Jansen8c19b882001-01-23 22:36:26 +0000237 genpluginproject("ppc", "ctb")
238 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen4a667c72002-01-11 12:39:03 +0000239 libraries=["InternetConfigLib"])
240 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000241 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000242
243if __name__ == '__main__':
244 genallprojects()
245
Jack Jansen1eda2032001-01-21 22:24:27 +0000246