blob: 6d2107b4633aa7729771aa8a87e81071d77d0f99 [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,
Jack Jansen7586b042001-08-20 15:31:56 +000043 libraries, extradirs, extraexportsymbols, outputdir)
Jack Jansen8c19b882001-01-23 22:36:26 +000044 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
Jack Jansen7586b042001-08-20 15:31:56 +000045 libraries, extradirs, extraexportsymbols, outputdir)
Jack Jansen8c19b882001-01-23 22:36:26 +000046 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:
Jack Jansen77105a92001-08-23 13:51:46 +000062 # For historical reasons an initial _ in the modulename
63 # is not reflected in the folder name
64 if module[0] == '_':
65 modulewithout_ = module[1:]
66 else:
67 modulewithout_ = module
68 moduledir = moduledir % modulewithout_
Jack Jansen6c502d72000-12-03 22:31:50 +000069 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
70 if os.path.exists(fn):
71 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000072 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000073 sources[0] = sourcefile
74 break
75 else:
76 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
77 sourcedirs = []
Jack Jansen8c19b882001-01-23 22:36:26 +000078 if architecture == "carbon":
79 prefixname = "mwerks_carbonplugin_config.h"
80 else:
81 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000082 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000083 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000084 "sources" : sources,
85 "extrasearchdirs" : sourcedirs + extradirs,
86 "libraries": libraries,
Jack Jansend39c2462001-08-19 22:29:57 +000087 "mac_outputdir" : outputdir,
Jack Jansen6c502d72000-12-03 22:31:50 +000088 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000089 "mac_targetname" : targetname,
90 "mac_dllname" : dllname,
91 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000092 }
Jack Jansen8c19b882001-01-23 22:36:26 +000093 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
94 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +000095
Jack Jansen1eda2032001-01-21 22:24:27 +000096def genallprojects(force=0):
97 global FORCEREBUILD
98 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +000099 # Standard Python modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000100 genpluginproject("all", "pyexpat",
Jack Jansen6c502d72000-12-03 22:31:50 +0000101 sources=["pyexpat.c"],
102 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +0000103 extradirs=["::::expat:*"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000104 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +0000105 libraries=["zlib.ppc.Lib"],
106 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000107 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000108 libraries=["gdbm.ppc.gusi.lib"],
109 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000110 genpluginproject("all", "_weakref", sources=["_weakref.c"])
111 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
Jack Jansen7c100082001-08-29 22:08:06 +0000112 # Example/test modules
Jack Jansen6e271182001-02-12 14:50:52 +0000113 genpluginproject("all", "_testcapi")
Jack Jansen7c100082001-08-29 22:08:06 +0000114 genpluginproject("all", "xx")
115 genpluginproject("all", "xxsubtype", sources=["xxsubtype.c"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000116
117 # bgen-generated Toolbox modules
Jack Jansen77105a92001-08-23 13:51:46 +0000118 genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
119 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon")
120 genpluginproject("ppc", "_App", libraries=["AppearanceLib"], outputdir="::Lib:Carbon")
121 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
122 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
123 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
124 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
125 genpluginproject("ppc", "_Ctl", libraries=["ControlsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000126 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000127 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
128 genpluginproject("ppc", "_Dlg", libraries=["DialogsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000129 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000130 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
131 genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon")
132 genpluginproject("all", "_Evt", outputdir="::Lib:Carbon")
133 genpluginproject("all", "_Fm", outputdir="::Lib:Carbon")
134 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
135 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon")
136 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
137 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
138 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
139 genpluginproject("ppc", "_Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000140 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000141 genpluginproject("all", "_Qd", outputdir="::Lib:Carbon")
142 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
143 genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon")
144 genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon")
145 genpluginproject("all", "_Res", outputdir="::Lib:Carbon")
146 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
147 genpluginproject("ppc", "_Snd", libraries=["SoundLib"], outputdir="::Lib:Carbon")
148 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
149 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
150 genpluginproject("ppc", "_TE", libraries=["DragLib"], outputdir="::Lib:Carbon")
151 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
152 genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
153 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
154 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
155 genpluginproject("ppc", "_Win", libraries=["WindowsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000156 outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000157 # Carbon Only?
Jack Jansen77105a92001-08-23 13:51:46 +0000158 genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000159
Jack Jansen6c502d72000-12-03 22:31:50 +0000160 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000161 genpluginproject("all", "calldll", sources=["calldll.c"])
162 genpluginproject("all", "ColorPicker")
163 genpluginproject("ppc", "Printing")
164 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000165 sources=[
166 "wastemodule.c",
167 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
168 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
169 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
170 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
171 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
172 'WEObjectHandlers.c',
173 'WETabs.c',
174 'WETabHooks.c'],
175 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000176 extradirs=[
177 '::::Waste 1.3 Distribution:*',
178 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000179 )
Jack Jansen8c982662001-01-24 16:02:07 +0000180 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
181 genpluginproject("carbon", "waste",
182 sources=[
183 "wastemodule.c",
184 "WEObjectHandlers.c",
185 "WETabs.c", "WETabHooks.c"],
186 libraries=["WASTE.Carbon.lib"],
187 extradirs=[
188 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
189 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
190 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
191 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
192 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000193 genpluginproject("ppc", "ctb")
194 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000195 libraries=["ICGlueCFM-PPC.lib"],
196 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000197 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
198 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000199 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000200
201if __name__ == '__main__':
202 genallprojects()
203
Jack Jansen1eda2032001-01-21 22:24:27 +0000204