blob: a22af2b2ec4a3fe845ebccfb00aa87f620d41978 [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 Jansenb55b7bb2001-01-03 16:44:56 +000013def relpath(base, path):
14 """Turn abs path into path relative to another. Only works for 2 abs paths
15 both pointing to folders"""
16 if not os.path.isabs(base) or not os.path.isabs(path):
17 raise 'Absolute paths only'
18 if base[-1] != ':':
19 base = base +':'
20 if path[-1] != ':':
21 path = path + ':'
22 basefields = string.split(base, os.sep)
23 pathfields = string.split(path, os.sep)
24 commonfields = len(os.path.commonprefix((basefields, pathfields)))
25 basefields = basefields[commonfields:]
26 pathfields = pathfields[commonfields:]
27 pathfields = ['']*len(basefields) + pathfields
28 return string.join(pathfields, os.sep)
29
Jack Jansen6c502d72000-12-03 22:31:50 +000030def genpluginproject(module,
31 project=None, projectdir=None,
32 sources=[], sourcedirs=[],
33 libraries=[], extradirs=[],
34 extraexportsymbols=[]):
35 if not project:
36 project = module + '.mcp'
37 if not projectdir:
38 projectdir = PROJECTDIR
39 if not sources:
40 sources = [module + 'module.c']
41 if not sourcedirs:
42 for moduledir in MODULEDIRS:
43 if '%' in moduledir:
44 moduledir = moduledir % module
45 fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
46 if os.path.exists(fn):
47 moduledir, sourcefile = os.path.split(fn)
48 sourcedirs = [moduledir]
49 sources[0] = sourcefile
50 break
51 else:
52 print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
53 sourcedirs = []
54 dict = {
55 "sysprefix" : sys.prefix,
56 "sources" : sources,
57 "extrasearchdirs" : sourcedirs + extradirs,
58 "libraries": libraries,
Jack Jansenb55b7bb2001-01-03 16:44:56 +000059 "mac_outputdir" : "::Plugins",
Jack Jansen6c502d72000-12-03 22:31:50 +000060 "extraexportsymbols" : extraexportsymbols,
61 }
62 mkcwproject.mkproject(os.path.join(projectdir, project), module, dict)
63
64def genallprojects():
65 # Standard Python modules
66 genpluginproject("ucnhash", sources=["ucnhash.c"])
67 genpluginproject("pyexpat",
68 sources=["pyexpat.c"],
69 libraries=["libexpat.ppc.lib"],
Jack Jansen52328162000-12-29 16:07:30 +000070 extradirs=["::::expat:*"])
Jack Jansen6c502d72000-12-03 22:31:50 +000071 genpluginproject("zlib",
72 libraries=["zlib.ppc.Lib"],
73 extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"])
74 genpluginproject("gdbm",
75 libraries=["gdbm.ppc.gusi.lib"],
76 extradirs=["::::gdbm:mac", "::::gdbm"])
77
78 # bgen-generated Toolbox modules
79 genpluginproject("App", libraries=["AppearanceLib"])
80 genpluginproject("Cm",
81 libraries=["QuickTimeLib"],
82 extraexportsymbols=[
83 "CmpObj_New",
84 "CmpObj_Convert",
85 "CmpInstObj_New",
86 "CmpInstObj_Convert",
87 ])
Jack Jansen6c502d72000-12-03 22:31:50 +000088 genpluginproject("Fm")
89 genpluginproject("Help")
90 genpluginproject("Icn", libraries=["IconServicesLib"])
91 genpluginproject("List")
Jack Jansen968c36d2000-12-12 21:53:48 +000092 genpluginproject("Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"], extradirs=["::Plugins"])
93 genpluginproject("Qdoffs",
94 extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"])
Jack Jansen6c502d72000-12-03 22:31:50 +000095 genpluginproject("Scrap")
96 genpluginproject("Snd", libraries=["SoundLib"])
97 genpluginproject("Sndihooks", sources=[":snd:Sndihooks.c"])
98 genpluginproject("TE", libraries=["DragLib"])
99
100 # Other Mac modules
101 genpluginproject("calldll", sources=["calldll.c"])
102 genpluginproject("ColorPicker")
103 genpluginproject("Printing")
104 genpluginproject("waste",
105 sources=[
106 "wastemodule.c",
107 'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c',
108 'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c',
109 'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c',
110 'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c',
111 'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c',
112 'WEObjectHandlers.c',
113 'WETabs.c',
114 'WETabHooks.c'],
115 libraries=['DragLib'],
116 extradirs=['::::Waste 1.3 Distribution:*']
117 )
118 genpluginproject("ctb")
119 genpluginproject("icglue", sources=["icgluemodule.c"],
120 libraries=["ICGlueCFM-PPC.lib"],
121 extradirs=["::::ICProgKit1.4:APIs"])
122 genpluginproject("macspeech", libraries=["SpeechLib"])
123
124if __name__ == '__main__':
125 genallprojects()
126