blob: 1841d0a282b29c91f3bb64ff1132be29e6b7db76 [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"])
112 genpluginproject("all", "_testcapi")
Jack Jansen6c502d72000-12-03 22:31:50 +0000113
114 # bgen-generated Toolbox modules
Jack Jansen77105a92001-08-23 13:51:46 +0000115 genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
116 genpluginproject("ppc", "_AE", libraries=["ObjectSupportLib"], outputdir="::Lib:Carbon")
117 genpluginproject("ppc", "_App", libraries=["AppearanceLib"], outputdir="::Lib:Carbon")
118 genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
119 genpluginproject("ppc", "_Cm", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
120 genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
121 genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
122 genpluginproject("ppc", "_Ctl", libraries=["ControlsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000123 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000124 genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
125 genpluginproject("ppc", "_Dlg", libraries=["DialogsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000126 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000127 genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
128 genpluginproject("ppc", "_Drag", libraries=["DragLib"], outputdir="::Lib:Carbon")
129 genpluginproject("all", "_Evt", outputdir="::Lib:Carbon")
130 genpluginproject("all", "_Fm", outputdir="::Lib:Carbon")
131 genpluginproject("ppc", "_Help", outputdir="::Lib:Carbon")
132 genpluginproject("ppc", "_Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon")
133 genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
134 genpluginproject("all", "_List", outputdir="::Lib:Carbon")
135 genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
136 genpluginproject("ppc", "_Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000137 outputdir="::Lib:Carbon")
Jack Jansen77105a92001-08-23 13:51:46 +0000138 genpluginproject("all", "_Qd", outputdir="::Lib:Carbon")
139 genpluginproject("ppc", "_Qt", libraries=["QuickTimeLib"], outputdir="::Lib:Carbon")
140 genpluginproject("carbon", "_Qt", outputdir="::Lib:Carbon")
141 genpluginproject("all", "_Qdoffs", outputdir="::Lib:Carbon")
142 genpluginproject("all", "_Res", outputdir="::Lib:Carbon")
143 genpluginproject("all", "_Scrap", outputdir="::Lib:Carbon")
144 genpluginproject("ppc", "_Snd", libraries=["SoundLib"], outputdir="::Lib:Carbon")
145 genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
146 genpluginproject("all", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
147 genpluginproject("ppc", "_TE", libraries=["DragLib"], outputdir="::Lib:Carbon")
148 genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
149 genpluginproject("ppc", "_Mlte", libraries=["Textension"], outputdir="::Lib:Carbon")
150 genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
151 genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
152 genpluginproject("ppc", "_Win", libraries=["WindowsLib", "AppearanceLib"],
Jack Jansend39c2462001-08-19 22:29:57 +0000153 outputdir="::Lib:Carbon")
Jack Jansen19864122001-07-13 20:57:47 +0000154 # Carbon Only?
Jack Jansen77105a92001-08-23 13:51:46 +0000155 genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon")
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000156
Jack Jansen6c502d72000-12-03 22:31:50 +0000157 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000158 genpluginproject("all", "calldll", sources=["calldll.c"])
159 genpluginproject("all", "ColorPicker")
160 genpluginproject("ppc", "Printing")
161 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000162 sources=[
163 "wastemodule.c",
164 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
165 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
166 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
167 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
168 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
169 'WEObjectHandlers.c',
170 'WETabs.c',
171 'WETabHooks.c'],
172 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000173 extradirs=[
174 '::::Waste 1.3 Distribution:*',
175 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000176 )
Jack Jansen8c982662001-01-24 16:02:07 +0000177 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
178 genpluginproject("carbon", "waste",
179 sources=[
180 "wastemodule.c",
181 "WEObjectHandlers.c",
182 "WETabs.c", "WETabHooks.c"],
183 libraries=["WASTE.Carbon.lib"],
184 extradirs=[
185 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
186 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
187 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
188 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
189 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000190 genpluginproject("ppc", "ctb")
191 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000192 libraries=["ICGlueCFM-PPC.lib"],
193 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000194 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
195 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000196 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000197
198if __name__ == '__main__':
199 genallprojects()
200
Jack Jansen1eda2032001-01-21 22:24:27 +0000201