blob: a1e7e57e89b519d6f3be7be67d38aa3bf9880145 [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",
39 libraryflags=None, stdlibraryflags=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 Jansen7586b042001-08-20 15:31:56 +000044 libraries, extradirs, extraexportsymbols, outputdir)
Jack Jansen8c19b882001-01-23 22:36:26 +000045 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
Jack Jansen7586b042001-08-20 15:31:56 +000046 libraries, extradirs, extraexportsymbols, outputdir)
Jack Jansen8c19b882001-01-23 22:36:26 +000047 return
48 templatename = "template-%s" % architecture
49 targetname = "%s.%s" % (module, architecture)
50 dllname = "%s.%s.slb" % (module, architecture)
Jack Jansen6c502d72000-12-03 22:31:50 +000051 if not project:
Jack Jansen8c19b882001-01-23 22:36:26 +000052 if architecture != "ppc":
53 project = "%s.%s.mcp"%(module, architecture)
54 else:
55 project = "%s.mcp"%module
Jack Jansen6c502d72000-12-03 22:31:50 +000056 if not projectdir:
57 projectdir = PROJECTDIR
58 if not sources:
59 sources = [module + 'module.c']
60 if not sourcedirs:
61 for moduledir in MODULEDIRS:
62 if '%' in moduledir:
Jack Jansen77105a92001-08-23 13:51:46 +000063 # For historical reasons an initial _ in the modulename
64 # is not reflected in the folder name
65 if module[0] == '_':
66 modulewithout_ = module[1:]
67 else:
68 modulewithout_ = module
69 moduledir = moduledir % modulewithout_
Jack Jansen6c502d72000-12-03 22:31:50 +000070 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
71 if os.path.exists(fn):
72 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000073 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000074 sources[0] = sourcefile
75 break
76 else:
77 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
78 sourcedirs = []
Jack Jansen8c19b882001-01-23 22:36:26 +000079 if architecture == "carbon":
80 prefixname = "mwerks_carbonplugin_config.h"
81 else:
82 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000083 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000084 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000085 "sources" : sources,
86 "extrasearchdirs" : sourcedirs + extradirs,
87 "libraries": libraries,
Jack Jansend39c2462001-08-19 22:29:57 +000088 "mac_outputdir" : outputdir,
Jack Jansen6c502d72000-12-03 22:31:50 +000089 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000090 "mac_targetname" : targetname,
91 "mac_dllname" : dllname,
92 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000093 }
Jack Jansenb3be2162001-11-30 14:16:36 +000094 if libraryflags:
95 dict['libraryflags'] = libraryflags
96 if stdlibraryflags:
97 dict['stdlibraryflags'] = stdlibraryflags
Jack Jansen8c19b882001-01-23 22:36:26 +000098 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
99 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +0000100
Jack Jansen1eda2032001-01-21 22:24:27 +0000101def genallprojects(force=0):
102 global FORCEREBUILD
103 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +0000104 # Standard Python modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000105 genpluginproject("all", "pyexpat",
Jack Jansen6c502d72000-12-03 22:31:50 +0000106 sources=["pyexpat.c"],
107 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +0000108 extradirs=["::::expat:*"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000109 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +0000110 libraries=["zlib.ppc.Lib"],
111 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000112 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000113 libraries=["gdbm.ppc.gusi.lib"],
114 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000115 genpluginproject("all", "_weakref", sources=["_weakref.c"])
116 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
Jack Jansen7c100082001-08-29 22:08:06 +0000117 # Example/test modules
Jack Jansen6e271182001-02-12 14:50:52 +0000118 genpluginproject("all", "_testcapi")
Jack Jansen7c100082001-08-29 22:08:06 +0000119 genpluginproject("all", "xx")
120 genpluginproject("all", "xxsubtype", sources=["xxsubtype.c"])
Jack Jansen6f1da002001-10-23 22:23:44 +0000121 genpluginproject("all", "_hotshot", sources=["_hotshot.c"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000122
123 # bgen-generated Toolbox modules
Jack Jansen77105a92001-08-23 13:51:46 +0000124 genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
125 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon")
126 genpluginproject("ppc", "_App", libraries=["AppearanceLib"], outputdir="::Lib:Carbon")
127 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
128 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
129 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
130 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
131 genpluginproject("ppc", "_Ctl", libraries=["ControlsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000132 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000133 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
134 genpluginproject("ppc", "_Dlg", libraries=["DialogsLib", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000135 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000136 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
137 genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon")
138 genpluginproject("all", "_Evt", outputdir="::Lib:Carbon")
139 genpluginproject("all", "_Fm", outputdir="::Lib:Carbon")
140 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
141 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon")
142 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
143 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
144 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
145 genpluginproject("ppc", "_Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansenb3be2162001-11-30 14:16:36 +0000146 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000147 genpluginproject("all", "_Qd", outputdir="::Lib:Carbon")
148 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
149 genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon")
150 genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon")
151 genpluginproject("all", "_Res", outputdir="::Lib:Carbon")
152 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
153 genpluginproject("ppc", "_Snd", libraries=["SoundLib"], outputdir="::Lib:Carbon")
154 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
155 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
156 genpluginproject("ppc", "_TE", libraries=["DragLib"], outputdir="::Lib:Carbon")
157 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
158 genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
159 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
160 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
Jack Jansenb3be2162001-11-30 14:16:36 +0000161 genpluginproject("ppc", "_Win", libraries=["CarbonAccessors.o", "WindowsLib", "AppearanceLib"],
162 libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000163 # Carbon Only?
Jack Jansen77105a92001-08-23 13:51:46 +0000164 genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon")
Jack Jansendf222d22001-11-06 15:56:56 +0000165 genpluginproject("carbon", "hfsplus")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000166
Jack Jansen6c502d72000-12-03 22:31:50 +0000167 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000168 genpluginproject("all", "calldll", sources=["calldll.c"])
169 genpluginproject("all", "ColorPicker")
170 genpluginproject("ppc", "Printing")
171 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000172 sources=[
173 "wastemodule.c",
174 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
175 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
176 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
177 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
178 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
179 'WEObjectHandlers.c',
180 'WETabs.c',
181 'WETabHooks.c'],
182 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000183 extradirs=[
184 '::::Waste 1.3 Distribution:*',
185 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000186 )
Jack Jansen8c982662001-01-24 16:02:07 +0000187 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
188 genpluginproject("carbon", "waste",
189 sources=[
190 "wastemodule.c",
191 "WEObjectHandlers.c",
192 "WETabs.c", "WETabHooks.c"],
193 libraries=["WASTE.Carbon.lib"],
194 extradirs=[
195 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
196 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
197 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
198 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
199 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000200 genpluginproject("ppc", "ctb")
201 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000202 libraries=["ICGlueCFM-PPC.lib"],
203 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000204 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
205 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000206 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000207
208if __name__ == '__main__':
209 genallprojects()
210
Jack Jansen1eda2032001-01-21 22:24:27 +0000211