blob: a785708e48fbd680bf2e15a84c04630a2745f656 [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 Jansen6c502d72000-12-03 22:31:50 +000033def genpluginproject(module,
34 project=None, projectdir=None,
35 sources=[], sourcedirs=[],
36 libraries=[], extradirs=[],
37 extraexportsymbols=[]):
38 if not project:
39 project = module + '.mcp'
40 if not projectdir:
41 projectdir = PROJECTDIR
42 if not sources:
43 sources = [module + 'module.c']
44 if not sourcedirs:
45 for moduledir in MODULEDIRS:
46 if '%' in moduledir:
47 moduledir = moduledir % module
48 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
49 if os.path.exists(fn):
50 moduledir, sourcefile = os.path.split(fn)
Jack Jansen1eda2032001-01-21 22:24:27 +000051 sourcedirs = [relpath(projectdir, moduledir)]
Jack Jansen6c502d72000-12-03 22:31:50 +000052 sources[0] = sourcefile
53 break
54 else:
55 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
56 sourcedirs = []
57 dict = {
Jack Jansen1eda2032001-01-21 22:24:27 +000058 "sysprefix" : relpath(projectdir, sys.prefix),
Jack Jansen6c502d72000-12-03 22:31:50 +000059 "sources" : sources,
60 "extrasearchdirs" : sourcedirs + extradirs,
61 "libraries": libraries,
Jack Jansenb55b7bb2001-01-03 16:44:56 +000062 "mac_outputdir" : "::Plugins",
Jack Jansen6c502d72000-12-03 22:31:50 +000063 "extraexportsymbols" : extraexportsymbols,
64 }
Jack Jansen1eda2032001-01-21 22:24:27 +000065 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD)
Jack Jansen6c502d72000-12-03 22:31:50 +000066
Jack Jansen1eda2032001-01-21 22:24:27 +000067def genallprojects(force=0):
68 global FORCEREBUILD
69 FORCEREBUILD = force
Jack Jansen6c502d72000-12-03 22:31:50 +000070 # Standard Python modules
71 genpluginproject("ucnhash", sources=["ucnhash.c"])
72 genpluginproject("pyexpat",
73 sources=["pyexpat.c"],
74 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +000075 extradirs=["::::expat:*"])
Jack Jansen6c502d72000-12-03 22:31:50 +000076 genpluginproject("zlib",
77 libraries=["zlib.ppc.Lib"],
78 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
79 genpluginproject("gdbm",
80 libraries=["gdbm.ppc.gusi.lib"],
81 extradirs=["::::gdbm:mac", "::::gdbm"])
82
83 # bgen-generated Toolbox modules
84 genpluginproject("App", libraries=["AppearanceLib"])
85 genpluginproject("Cm",
86 libraries=["QuickTimeLib"],
87 extraexportsymbols=[
88 "CmpObj_New",
89 "CmpObj_Convert",
90 "CmpInstObj_New",
91 "CmpInstObj_Convert",
92 ])
Jack Jansen6c502d72000-12-03 22:31:50 +000093 genpluginproject("Fm")
94 genpluginproject("Help")
95 genpluginproject("Icn", libraries=["IconServicesLib"])
96 genpluginproject("List")
Jack Jansen968c36d2000-12-12 21:53:48 +000097 genpluginproject("Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"], extradirs=["::Plugins"])
98 genpluginproject("Qdoffs",
99 extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"])
Jack Jansen6c502d72000-12-03 22:31:50 +0000100 genpluginproject("Scrap")
101 genpluginproject("Snd", libraries=["SoundLib"])
102 genpluginproject("Sndihooks", sources=[":snd:Sndihooks.c"])
103 genpluginproject("TE", libraries=["DragLib"])
104
105 # Other Mac modules
106 genpluginproject("calldll", sources=["calldll.c"])
107 genpluginproject("ColorPicker")
108 genpluginproject("Printing")
109 genpluginproject("waste",
110 sources=[
111 "wastemodule.c",
112 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
113 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
114 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
115 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
116 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
117 'WEObjectHandlers.c',
118 'WETabs.c',
119 'WETabHooks.c'],
120 libraries=['DragLib'],
121 extradirs=['::::Waste 1.3 Distribution:*']
122 )
123 genpluginproject("ctb")
124 genpluginproject("icglue", sources=["icgluemodule.c"],
125 libraries=["ICGlueCFM-PPC.lib"],
126 extradirs=["::::ICProgKit1.4:APIs"])
127 genpluginproject("macspeech", libraries=["SpeechLib"])
128
129if __name__ == '__main__':
130 genallprojects()
131
Jack Jansen1eda2032001-01-21 22:24:27 +0000132