blob: 398677132b96422c464d093ffdc37c8db93d44db [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
6PROJECTDIR = os.path.join(sys.prefix, ":Mac:Build")
7MODULEDIRS = [ # Relative to projectdirs
8 "::Modules:%s",
9 "::Modules",
10 ":::Modules",
11]
12
Jack Jansen1eda2032001-01-21 22:24:27 +000013# Global variable to control forced rebuild (otherwise the project is only rebuilt
14# when it is changed)
15FORCEREBUILD=0
16
Jack Jansenb55b7bb2001-01-03 16:44:56 +000017def relpath(base, path):
18 """Turn abs path into path relative to another. Only works for 2 abs paths
19 both pointing to folders"""
20 if not os.path.isabs(base) or not os.path.isabs(path):
21 raise 'Absolute paths only'
Jack Jansen1eda2032001-01-21 22:24:27 +000022 if base[-1] == ':':
23 base = base[:-1]
Jack Jansenb55b7bb2001-01-03 16:44:56 +000024 basefields = string.split(base, os.sep)
25 pathfields = string.split(path, os.sep)
26 commonfields = len(os.path.commonprefix((basefields, pathfields)))
27 basefields = basefields[commonfields:]
28 pathfields = pathfields[commonfields:]
Jack Jansen1eda2032001-01-21 22:24:27 +000029 pathfields = ['']*(len(basefields)+1) + pathfields
30 rv = string.join(pathfields, os.sep)
31 return rv
Jack Jansenb55b7bb2001-01-03 16:44:56 +000032
Jack Jansen8c19b882001-01-23 22:36:26 +000033def genpluginproject(architecture, module,
Jack Jansen6c502d72000-12-03 22:31:50 +000034 project=None, projectdir=None,
35 sources=[], sourcedirs=[],
36 libraries=[], extradirs=[],
37 extraexportsymbols=[]):
Jack Jansen8c19b882001-01-23 22:36:26 +000038 if architecture == "all":
39 # For the time being we generate two project files. Not as nice as
40 # a single multitarget project, but easier to implement for now.
41 genpluginproject("ppc", module, project, projectdir, sources, sourcedirs,
42 libraries, extradirs, extraexportsymbols)
43 genpluginproject("carbon", module, project, projectdir, sources, sourcedirs,
44 libraries, extradirs, extraexportsymbols)
45 return
46 templatename = "template-%s" % architecture
47 targetname = "%s.%s" % (module, architecture)
48 dllname = "%s.%s.slb" % (module, architecture)
Jack Jansen6c502d72000-12-03 22:31:50 +000049 if not project:
Jack Jansen8c19b882001-01-23 22:36:26 +000050 if architecture != "ppc":
51 project = "%s.%s.mcp"%(module, architecture)
52 else:
53 project = "%s.mcp"%module
Jack Jansen6c502d72000-12-03 22:31:50 +000054 if not projectdir:
55 projectdir = PROJECTDIR
56 if not sources:
57 sources = [module + 'module.c']
58 if not sourcedirs:
59 for moduledir in MODULEDIRS:
60 if '%' in moduledir:
61 moduledir = moduledir % module
62 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
63 if os.path.exists(fn):
64 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000065 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000066 sources[0] = sourcefile
67 break
68 else:
69 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
70 sourcedirs = []
Jack Jansen8c19b882001-01-23 22:36:26 +000071 if architecture == "carbon":
72 prefixname = "mwerks_carbonplugin_config.h"
73 else:
74 prefixname = "mwerks_plugin_config.h"
Jack Jansen6c502d72000-12-03 22:31:50 +000075 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000076 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000077 "sources" : sources,
78 "extrasearchdirs" : sourcedirs + extradirs,
79 "libraries": libraries,
Jack Jansenb55b7bb2001-01-03 16:44:56 +000080 "mac_outputdir" : "::Plugins",
Jack Jansen6c502d72000-12-03 22:31:50 +000081 "extraexportsymbols" : extraexportsymbols,
Jack Jansen8c19b882001-01-23 22:36:26 +000082 "mac_targetname" : targetname,
83 "mac_dllname" : dllname,
84 "prefixname" : prefixname,
Jack Jansen6c502d72000-12-03 22:31:50 +000085 }
Jack Jansen8c19b882001-01-23 22:36:26 +000086 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,
87 force=FORCEREBUILD, templatename=templatename)
Jack Jansen6c502d72000-12-03 22:31:50 +000088
Jack Jansen1eda2032001-01-21 22:24:27 +000089def genallprojects(force=0):
90 global FORCEREBUILD
91 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +000092 # Standard Python modules
Jack Jansen8c19b882001-01-23 22:36:26 +000093 genpluginproject("all", "pyexpat",
Jack Jansen6c502d72000-12-03 22:31:50 +000094 sources=["pyexpat.c"],
95 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +000096 extradirs=["::::expat:*"])
Jack Jansen8c19b882001-01-23 22:36:26 +000097 genpluginproject("all", "zlib",
Jack Jansen6c502d72000-12-03 22:31:50 +000098 libraries=["zlib.ppc.Lib"],
99 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000100 genpluginproject("all", "gdbm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000101 libraries=["gdbm.ppc.gusi.lib"],
102 extradirs=["::::gdbm:mac", "::::gdbm"])
103
104 # bgen-generated Toolbox modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000105 genpluginproject("ppc", "App", libraries=["AppearanceLib"])
106 genpluginproject("carbon", "App")
107 genpluginproject("ppc", "Cm",
Jack Jansen6c502d72000-12-03 22:31:50 +0000108 libraries=["QuickTimeLib"],
109 extraexportsymbols=[
110 "CmpObj_New",
111 "CmpObj_Convert",
112 "CmpInstObj_New",
113 "CmpInstObj_Convert",
114 ])
Jack Jansen8c19b882001-01-23 22:36:26 +0000115 genpluginproject("carbon", "Cm",
116 extraexportsymbols=[
117 "CmpObj_New",
118 "CmpObj_Convert",
119 "CmpInstObj_New",
120 "CmpInstObj_Convert",
121 ])
122 genpluginproject("all", "Fm")
123 genpluginproject("ppc", "Help")
124 genpluginproject("ppc", "Icn", libraries=["IconServicesLib"])
125 genpluginproject("carbon", "Icn")
126 genpluginproject("all", "List")
127 genpluginproject("ppc", "Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"],
128 extradirs=["::Plugins"])
129 genpluginproject("carbon", "Qt", libraries=["Cm.carbon.slb", "Qdoffs.carbon.slb"],
130 extradirs=["::Plugins"])
131 genpluginproject("all", "Qdoffs",
Jack Jansen968c36d2000-12-12 21:53:48 +0000132 extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"])
Jack Jansen8c982662001-01-24 16:02:07 +0000133 genpluginproject("all", "Scrap")
Jack Jansen8c19b882001-01-23 22:36:26 +0000134 genpluginproject("ppc", "Snd", libraries=["SoundLib"])
135 genpluginproject("carbon", "Snd")
136 genpluginproject("all", "Sndihooks", sources=[":snd:Sndihooks.c"])
137 genpluginproject("ppc", "TE", libraries=["DragLib"])
138 genpluginproject("carbon", "TE")
Jack Jansen6c502d72000-12-03 22:31:50 +0000139
140 # Other Mac modules
Jack Jansen8c19b882001-01-23 22:36:26 +0000141 genpluginproject("all", "calldll", sources=["calldll.c"])
142 genpluginproject("all", "ColorPicker")
143 genpluginproject("ppc", "Printing")
144 genpluginproject("ppc", "waste",
Jack Jansen6c502d72000-12-03 22:31:50 +0000145 sources=[
146 "wastemodule.c",
147 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
148 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
149 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
150 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
151 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
152 'WEObjectHandlers.c',
153 'WETabs.c',
154 'WETabHooks.c'],
155 libraries=['DragLib'],
Jack Jansen0e1c24a2001-01-22 14:50:05 +0000156 extradirs=[
157 '::::Waste 1.3 Distribution:*',
158 '::::ICProgKit1.4:APIs']
Jack Jansen6c502d72000-12-03 22:31:50 +0000159 )
Jack Jansen8c982662001-01-24 16:02:07 +0000160 # This is a hack, combining parts of Waste 2.0 with parts of 1.3
161 genpluginproject("carbon", "waste",
162 sources=[
163 "wastemodule.c",
164 "WEObjectHandlers.c",
165 "WETabs.c", "WETabHooks.c"],
166 libraries=["WASTE.Carbon.lib"],
167 extradirs=[
168 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers',
169 '{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries',
170 '::::Waste 1.3 Distribution:Extras:Sample Object Handlers',
171 '::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2']
172 )
Jack Jansen8c19b882001-01-23 22:36:26 +0000173 genpluginproject("ppc", "ctb")
174 genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],
Jack Jansen6c502d72000-12-03 22:31:50 +0000175 libraries=["ICGlueCFM-PPC.lib"],
176 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen5a8115c2001-01-29 13:27:46 +0000177 genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],
178 extradirs=["::::ICProgKit1.4:APIs"])
Jack Jansen8c19b882001-01-23 22:36:26 +0000179 genpluginproject("ppc", "macspeech", libraries=["SpeechLib"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000180
181if __name__ == '__main__':
182 genallprojects()
183
Jack Jansen1eda2032001-01-21 22:24:27 +0000184