blob: 0ee6bcea03e443518a1132173e7e782ddec5b71a [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=[],
38 extraexportsymbols=[]):
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,
43 libraries, extradirs, extraexportsymbols)
44 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
45 libraries, extradirs, extraexportsymbols)
46 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:
62 moduledir = moduledir % module
63 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
64 if os.path.exists(fn):
65 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000066 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000067 sources[0] = sourcefile
68 break
69 else:
70 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
71 sourcedirs = []
Jack Jansen8c19b882001-01-23 22:36:26 +000072 if architecture == "carbon":
73 prefixname = "mwerks_carbonplugin_config.h"
74 else:
75 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000076 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000077 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000078 "sources" : sources,
79 "extrasearchdirs" : sourcedirs + extradirs,
80 "libraries": libraries,
Jack Jansenb55b7bb2001-01-03 16:44:56 +000081 "mac_outputdir" : "::Plugins",
Jack Jansen6c502d72000-12-03 22:31:50 +000082 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000083 "mac_targetname" : targetname,
84 "mac_dllname" : dllname,
85 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000086 }
Jack Jansen8c19b882001-01-23 22:36:26 +000087 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
88 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +000089
Jack Jansen1eda2032001-01-21 22:24:27 +000090def genallprojects(force=0):
91 global FORCEREBUILD
92 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +000093 # Standard Python modules
Jack Jansen8c19b882001-01-23 22:36:26 +000094 genpluginproject("all", "pyexpat",
Jack Jansen6c502d72000-12-03 22:31:50 +000095 sources=["pyexpat.c"],
96 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +000097 extradirs=["::::expat:*"])
Jack Jansen8c19b882001-01-23 22:36:26 +000098 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +000099 libraries=["zlib.ppc.Lib"],
100 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000101 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000102 libraries=["gdbm.ppc.gusi.lib"],
103 extradirs=["::::gdbm:mac", "::::gdbm"])
Jack Jansen6e271182001-02-12 14:50:52 +0000104 genpluginproject("all", "_weakref", sources=["_weakref.c"])
105 genpluginproject("all", "_symtable", sources=["symtablemodule.c"])
106 genpluginproject("all", "_testcapi")
Jack Jansen6c502d72000-12-03 22:31:50 +0000107
108 # bgen-generated Toolbox modules
Jack Jansen67992b72001-08-07 13:53:25 +0000109 genpluginproject("carbon", "AE")
110 genpluginproject("ppc", "AE", libraries=["ObjectSupportLib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000111 genpluginproject("ppc", "App", libraries=["AppearanceLib"])
112 genpluginproject("carbon", "App")
Jack Jansene8f53bb2001-05-17 22:12:55 +0000113 genpluginproject("ppc", "Cm", libraries=["QuickTimeLib"])
114 genpluginproject("carbon", "Cm")
Jack Jansen67992b72001-08-07 13:53:25 +0000115 genpluginproject("carbon", "Ctl")
116 genpluginproject("ppc", "Ctl", libraries=["ControlsLib", "AppearanceLib"])
117 genpluginproject("carbon", "Dlg")
118 genpluginproject("ppc", "Dlg", libraries=["DialogsLib", "AppearanceLib"])
119 genpluginproject("carbon", "Drag")
120 genpluginproject("ppc", "Drag", libraries=["DragLib"])
121 genpluginproject("all", "Evt")
Jack Jansen8c19b882001-01-23 22:36:26 +0000122 genpluginproject("all", "Fm")
123 genpluginproject("ppc", "Help")
124 genpluginproject("ppc", "Icn", libraries=["IconServicesLib"])
125 genpluginproject("carbon", "Icn")
126 genpluginproject("all", "List")
Jack Jansen67992b72001-08-07 13:53:25 +0000127 genpluginproject("carbon", "Menu")
128 genpluginproject("ppc", "Menu", libraries=["MenusLib", "ContextualMenu", "AppearanceLib"])
129 genpluginproject("all", "Qd")
Jack Jansene8f53bb2001-05-17 22:12:55 +0000130 genpluginproject("ppc", "Qt", libraries=["QuickTimeLib"])
Jack Jansene8f53bb2001-05-17 22:12:55 +0000131 genpluginproject("carbon", "Qt")
Jack Jansene8f53bb2001-05-17 22:12:55 +0000132 genpluginproject("all", "Qdoffs")
Jack Jansen67992b72001-08-07 13:53:25 +0000133 genpluginproject("all", "Res")
Jack Jansen8c982662001-01-24 16:02:07 +0000134 genpluginproject("all", "Scrap")
Jack Jansen8c19b882001-01-23 22:36:26 +0000135 genpluginproject("ppc", "Snd", libraries=["SoundLib"])
136 genpluginproject("carbon", "Snd")
137 genpluginproject("all", "Sndihooks", sources=[":snd:Sndihooks.c"])
138 genpluginproject("ppc", "TE", libraries=["DragLib"])
139 genpluginproject("carbon", "TE")
Jack Jansen19864122001-07-13 20:57:47 +0000140 genpluginproject("ppc", "Mlte", libraries=["Textension"])
141 genpluginproject("carbon", "Mlte")
Jack Jansen67992b72001-08-07 13:53:25 +0000142 genpluginproject("carbon", "Win")
143 genpluginproject("ppc", "Win", libraries=["WindowsLib", "AppearanceLib"])
Jack Jansen19864122001-07-13 20:57:47 +0000144 # Carbon Only?
Jack Jansenf4b9fb72001-06-26 21:52:08 +0000145 genpluginproject("carbon", "CF")
146
Jack Jansen6c502d72000-12-03 22:31:50 +0000147 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000148 genpluginproject("all", "calldll", sources=["calldll.c"])
149 genpluginproject("all", "ColorPicker")
150 genpluginproject("ppc", "Printing")
151 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000152 sources=[
153 "wastemodule.c",
154 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
155 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
156 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
157 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
158 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
159 'WEObjectHandlers.c',
160 'WETabs.c',
161 'WETabHooks.c'],
162 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000163 extradirs=[
164 '::::Waste 1.3 Distribution:*',
165 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000166 )
Jack Jansen8c982662001-01-24 16:02:07 +0000167 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
168 genpluginproject("carbon", "waste",
169 sources=[
170 "wastemodule.c",
171 "WEObjectHandlers.c",
172 "WETabs.c", "WETabHooks.c"],
173 libraries=["WASTE.Carbon.lib"],
174 extradirs=[
175 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
176 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
177 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
178 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
179 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000180 genpluginproject("ppc", "ctb")
181 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000182 libraries=["ICGlueCFM-PPC.lib"],
183 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000184 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
185 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000186 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000187
188if __name__ == '__main__':
189 genallprojects()
190
Jack Jansen1eda2032001-01-21 22:24:27 +0000191