blob: ec91ac907640cfecb7bba70e11b6c72cfb0d1d3f [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 Jansenc70815a2002-06-26 22:06:08 +00006CARBON_ONLY=1
7
Jack Jansene791a642001-08-16 20:39:17 +00008PYTHONDIR = sys.prefix
9PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build")
Jack Jansen6c502d72000-12-03 22:31:50 +000010MODULEDIRS = [ # Relative to projectdirs
11 "::Modules:%s",
12 "::Modules",
13 ":::Modules",
14]
15
Jack Jansen1eda2032001-01-21 22:24:27 +000016# Global variable to control forced rebuild (otherwise the project is only rebuilt
17# when it is changed)
18FORCEREBUILD=0
19
Jack Jansenb55b7bb2001-01-03 16:44:56 +000020def relpath(base, path):
21 """Turn abs path into path relative to another. Only works for 2 abs paths
22 both pointing to folders"""
23 if not os.path.isabs(base) or not os.path.isabs(path):
24 raise 'Absolute paths only'
Jack Jansen1eda2032001-01-21 22:24:27 +000025 if base[-1] == ':':
26 base = base[:-1]
Jack Jansenb55b7bb2001-01-03 16:44:56 +000027 basefields = string.split(base, os.sep)
28 pathfields = string.split(path, os.sep)
29 commonfields = len(os.path.commonprefix((basefields, pathfields)))
30 basefields = basefields[commonfields:]
31 pathfields = pathfields[commonfields:]
Jack Jansen1eda2032001-01-21 22:24:27 +000032 pathfields = ['']*(len(basefields)+1) + pathfields
33 rv = string.join(pathfields, os.sep)
34 return rv
Jack Jansenb55b7bb2001-01-03 16:44:56 +000035
Jack Jansen8c19b882001-01-23 22:36:26 +000036def genpluginproject(architecture, module,
Jack Jansen6c502d72000-12-03 22:31:50 +000037 project=None, projectdir=None,
38 sources=[], sourcedirs=[],
39 libraries=[], extradirs=[],
Jack Jansenb3be2162001-11-30 14:16:36 +000040 extraexportsymbols=[], outputdir=":::Lib:lib-dynload",
Jack Jansenb66e1a32002-05-23 22:34:18 +000041 libraryflags=None, stdlibraryflags=None, prefixname=None,
42 initialize=None):
Jack Jansenc70815a2002-06-26 22:06:08 +000043 if CARBON_ONLY and architecture == "ppc":
44 return
Jack Jansen8c19b882001-01-23 22:36:26 +000045 if architecture == "all":
46 # For the time being we generate two project files. Not as nice as
47 # a single multitarget project, but easier to implement for now.
48 genpluginproject("ppc", module, project, projectdir, sources, sourcedirs,
Jack Jansen9051e0e2002-03-22 14:15:07 +000049 libraries, extradirs, extraexportsymbols, outputdir, libraryflags,
Jack Jansenb66e1a32002-05-23 22:34:18 +000050 stdlibraryflags, prefixname, initialize)
Jack Jansen8c19b882001-01-23 22:36:26 +000051 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
Jack Jansen9051e0e2002-03-22 14:15:07 +000052 libraries, extradirs, extraexportsymbols, outputdir, libraryflags,
Jack Jansenb66e1a32002-05-23 22:34:18 +000053 stdlibraryflags, prefixname, initialize)
Jack Jansen8c19b882001-01-23 22:36:26 +000054 return
55 templatename = "template-%s" % architecture
56 targetname = "%s.%s" % (module, architecture)
57 dllname = "%s.%s.slb" % (module, architecture)
Jack Jansen6c502d72000-12-03 22:31:50 +000058 if not project:
Jack Jansen8c19b882001-01-23 22:36:26 +000059 if architecture != "ppc":
60 project = "%s.%s.mcp"%(module, architecture)
61 else:
62 project = "%s.mcp"%module
Jack Jansen6c502d72000-12-03 22:31:50 +000063 if not projectdir:
64 projectdir = PROJECTDIR
65 if not sources:
66 sources = [module + 'module.c']
67 if not sourcedirs:
68 for moduledir in MODULEDIRS:
69 if '%' in moduledir:
Jack Jansen77105a92001-08-23 13:51:46 +000070 # For historical reasons an initial _ in the modulename
71 # is not reflected in the folder name
72 if module[0] == '_':
73 modulewithout_ = module[1:]
74 else:
75 modulewithout_ = module
76 moduledir = moduledir % modulewithout_
Jack Jansen6c502d72000-12-03 22:31:50 +000077 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
78 if os.path.exists(fn):
79 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000080 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000081 sources[0] = sourcefile
82 break
83 else:
84 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
85 sourcedirs = []
Jack Jansen86c4d642002-03-14 23:14:43 +000086 if prefixname:
87 pass
88 elif architecture == "carbon":
Jack Jansenc70815a2002-06-26 22:06:08 +000089 prefixname = "mwerks_shcarbon_pch"
Jack Jansen8c19b882001-01-23 22:36:26 +000090 else:
91 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000092 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000093 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000094 "sources" : sources,
95 "extrasearchdirs" : sourcedirs + extradirs,
96 "libraries": libraries,
Jack Jansend39c2462001-08-19 22:29:57 +000097 "mac_outputdir" : outputdir,
Jack Jansen6c502d72000-12-03 22:31:50 +000098 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000099 "mac_targetname" : targetname,
100 "mac_dllname" : dllname,
101 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +0000102 }
Jack Jansenb3be2162001-11-30 14:16:36 +0000103 if libraryflags:
104 dict['libraryflags'] = libraryflags
105 if stdlibraryflags:
106 dict['stdlibraryflags'] = stdlibraryflags
Jack Jansenb66e1a32002-05-23 22:34:18 +0000107 if initialize:
108 dict['initialize'] = initialize
Jack Jansen8c19b882001-01-23 22:36:26 +0000109 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
110 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +0000111
Jack Jansen1eda2032001-01-21 22:24:27 +0000112def genallprojects(force=0):
113 global FORCEREBUILD
114 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +0000115 # Standard Python modules
Jack Jansen86c4d642002-03-14 23:14:43 +0000116 genpluginproject("ppc", "pyexpat",
117 sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"],
118 extradirs=[":::Modules:expat"],
Jack Jansenc70815a2002-06-26 22:06:08 +0000119 prefixname="mwerks_shared_config.h"
Jack Jansen86c4d642002-03-14 23:14:43 +0000120 )
121 genpluginproject("carbon", "pyexpat",
122 sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"],
123 extradirs=[":::Modules:expat"],
Jack Jansenc70815a2002-06-26 22:06:08 +0000124 prefixname="mwerks_shcarbon_config.h"
Jack Jansen86c4d642002-03-14 23:14:43 +0000125 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000126 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +0000127 libraries=["zlib.ppc.Lib"],
128 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000129 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000130 libraries=["gdbm.ppc.gusi.lib"],
131 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000132 genpluginproject("all", "_weakref", sources=["_weakref.c"])
133 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
Jack Jansen7c100082001-08-29 22:08:06 +0000134 # Example/test modules
Jack Jansen6e271182001-02-12 14:50:52 +0000135 genpluginproject("all", "_testcapi")
Jack Jansen7c100082001-08-29 22:08:06 +0000136 genpluginproject("all", "xx")
137 genpluginproject("all", "xxsubtype", sources=["xxsubtype.c"])
Jack Jansen6f1da002001-10-23 22:23:44 +0000138 genpluginproject("all", "_hotshot", sources=["_hotshot.c"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000139
140 # bgen-generated Toolbox modules
Jack Jansen77105a92001-08-23 13:51:46 +0000141 genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000142 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"],
143 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000144 genpluginproject("ppc", "_App", libraries=["CarbonAccessors.o", "AppearanceLib"],
145 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000146 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000147 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"],
148 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000149 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
Just van Rossum11ccf3c2001-12-13 13:21:38 +0000150 # XXX can't work properly because we need to set a custom fragment initializer
151 #genpluginproject("carbon", "_CG",
152 # sources=["_CGModule.c", "CFMLateImport.c"],
153 # libraries=["CGStubLib"],
154 # outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000155 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000156 genpluginproject("ppc", "_Ctl", libraries=["CarbonAccessors.o", "ControlsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000157 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000158 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000159 genpluginproject("ppc", "_Dlg", libraries=["CarbonAccessors.o", "DialogsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000160 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000161 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000162 genpluginproject("ppc", "_Drag", libraries=["DragLib"],
163 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
164 genpluginproject("all", "_Evt",
165 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
166 genpluginproject("all", "_Fm",
167 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000168 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000169 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"],
170 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen3bd3fed2002-08-05 14:12:24 +0000171 genpluginproject("carbon", "_IBCarbon", sources=[":ibcarbon:_IBCarbon.c"],
172 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000173 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
174 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
175 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000176 genpluginproject("ppc", "_Menu", libraries=["CarbonAccessors.o", "MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000177 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000178 genpluginproject("all", "_Qd",
179 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
180 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"],
181 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
182 genpluginproject("carbon", "_Qt",
183 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
184 genpluginproject("all", "_Qdoffs",
185 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen9051e0e2002-03-22 14:15:07 +0000186 genpluginproject("all", "_Res",
187 stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000188 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
Jack Jansena7594db2001-12-05 22:46:23 +0000189 genpluginproject("ppc", "_Snd", libraries=["CarbonAccessors.o", "SoundLib"], outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000190 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
191 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000192 genpluginproject("ppc", "_TE", libraries=["CarbonAccessors.o", "DragLib"],
193 stdlibraryflags="Debug, WeakImport",
194 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000195 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
Jack Jansen5ee24ae2002-03-24 22:59:16 +0000196 genpluginproject("ppc", "_Mlte", libraries=["Textension"],
197 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000198 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
199 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
Jack Jansenb3be2162001-11-30 14:16:36 +0000200 genpluginproject("ppc", "_Win", libraries=["CarbonAccessors.o", "WindowsLib", "AppearanceLib"],
201 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000202 # Carbon Only?
Jack Jansen66e794d2002-07-22 12:32:31 +0000203 genpluginproject("carbon", "_CF", sources=["_CFmodule.c", "pycfbridge.c"], outputdir="::Lib:Carbon")
Just van Rossumaa6e83f2001-12-12 22:42:37 +0000204 genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon")
Jack Jansendf222d22001-11-06 15:56:56 +0000205 genpluginproject("carbon", "hfsplus")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000206
Jack Jansen6c502d72000-12-03 22:31:50 +0000207 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000208 genpluginproject("all", "calldll", sources=["calldll.c"])
209 genpluginproject("all", "ColorPicker")
210 genpluginproject("ppc", "Printing")
Jack Jansen4a667c72002-01-11 12:39:03 +0000211## genpluginproject("ppc", "waste",
212## sources=[
213## "wastemodule.c",
214## 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
215## 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
216## 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
217## 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
218## 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
219## 'WEObjectHandlers.c',
220## 'WETabs.c',
221## 'WETabHooks.c'],
222## libraries=['DragLib'],
223## extradirs=[
224## '::::Waste 1.3 Distribution:*',
225## '::::ICProgKit1.4:APIs']
226## )
227 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
Jack Jansen8c19b882001-01-23 22:36:26 +0000228 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000229 sources=[
230 "wastemodule.c",
Jack Jansen4a667c72002-01-11 12:39:03 +0000231 "WEObjectHandlers.c",
232 "WETabs.c", "WETabHooks.c"],
233 libraries=[
234 "WASTE.PPC.lib",
235 "TextCommon",
236 "UnicodeConverter",
237 "DragLib",
238 ],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000239 extradirs=[
Jack Jansen4a667c72002-01-11 12:39:03 +0000240 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
241 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
242 '::wastemods',
243 ]
Jack Jansen6c502d72000-12-03 22:31:50 +0000244 )
Jack Jansen8c982662001-01-24 16:02:07 +0000245 genpluginproject("carbon", "waste",
246 sources=[
247 "wastemodule.c",
248 "WEObjectHandlers.c",
249 "WETabs.c", "WETabHooks.c"],
250 libraries=["WASTE.Carbon.lib"],
251 extradirs=[
252 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
253 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
Jack Jansen4a667c72002-01-11 12:39:03 +0000254 '::wastemods',
255 ]
Jack Jansen8c982662001-01-24 16:02:07 +0000256 )
Jack Jansen4a667c72002-01-11 12:39:03 +0000257## '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
258## '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
Jack Jansen8c19b882001-01-23 22:36:26 +0000259 genpluginproject("ppc", "ctb")
260 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen4a667c72002-01-11 12:39:03 +0000261 libraries=["InternetConfigLib"])
262 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000263 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000264
265if __name__ == '__main__':
266 genallprojects()
267
Jack Jansen1eda2032001-01-21 22:24:27 +0000268