| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 1 | import mkcwproject | 
 | 2 | import sys | 
 | 3 | import os | 
| Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 4 | import string | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 5 |  | 
 | 6 | PROJECTDIR = os.path.join(sys.prefix, ":Mac:Build") | 
 | 7 | MODULEDIRS = [	# Relative to projectdirs | 
 | 8 | 	"::Modules:%s", | 
 | 9 | 	"::Modules", | 
 | 10 | 	":::Modules", | 
 | 11 | ] | 
 | 12 |  | 
| Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 13 | # Global variable to control forced rebuild (otherwise the project is only rebuilt | 
 | 14 | # when it is changed) | 
 | 15 | FORCEREBUILD=0 | 
 | 16 |  | 
| Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 17 | def 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 Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 22 | 	if base[-1] == ':': | 
 | 23 | 		base = base[:-1] | 
| Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 24 | 	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 Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 29 | 	pathfields = ['']*(len(basefields)+1) + pathfields | 
 | 30 | 	rv = string.join(pathfields, os.sep) | 
 | 31 | 	return rv | 
| Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 32 |  | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 33 | def 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 Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 51 | 				sourcedirs = [relpath(projectdir, moduledir)] | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 52 | 				sources[0] = sourcefile | 
 | 53 | 				break | 
 | 54 | 		else: | 
 | 55 | 			print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) | 
 | 56 | 			sourcedirs = [] | 
 | 57 | 	dict = { | 
| Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 58 | 		"sysprefix" : relpath(projectdir, sys.prefix), | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 59 | 		"sources" : sources, | 
 | 60 | 		"extrasearchdirs" : sourcedirs + extradirs, | 
 | 61 | 		"libraries": libraries, | 
| Jack Jansen | b55b7bb | 2001-01-03 16:44:56 +0000 | [diff] [blame] | 62 | 		"mac_outputdir" : "::Plugins", | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 63 | 		"extraexportsymbols" : extraexportsymbols, | 
 | 64 | 	} | 
| Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 65 | 	mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD) | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 66 |  | 
| Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 67 | def	genallprojects(force=0): | 
 | 68 | 	global FORCEREBUILD | 
 | 69 | 	FORCEREBUILD = force | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 70 | 	# Standard Python modules | 
 | 71 | 	genpluginproject("ucnhash", sources=["ucnhash.c"]) | 
 | 72 | 	genpluginproject("pyexpat",  | 
 | 73 | 		sources=["pyexpat.c"],  | 
 | 74 | 		libraries=["libexpat.ppc.lib"],  | 
| Jack Jansen | 5232816 | 2000-12-29 16:07:30 +0000 | [diff] [blame] | 75 | 		extradirs=["::::expat:*"]) | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 76 | 	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 Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 93 | 	genpluginproject("Fm") | 
 | 94 | 	genpluginproject("Help") | 
 | 95 | 	genpluginproject("Icn", libraries=["IconServicesLib"]) | 
 | 96 | 	genpluginproject("List") | 
| Jack Jansen | 968c36d | 2000-12-12 21:53:48 +0000 | [diff] [blame] | 97 | 	genpluginproject("Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"], extradirs=["::Plugins"]) | 
 | 98 | 	genpluginproject("Qdoffs", | 
 | 99 | 		extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"]) | 
| Jack Jansen | 6c502d7 | 2000-12-03 22:31:50 +0000 | [diff] [blame] | 100 | 	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 |  | 
 | 129 | if __name__ == '__main__': | 
 | 130 | 	genallprojects() | 
 | 131 | 	 | 
| Jack Jansen | 1eda203 | 2001-01-21 22:24:27 +0000 | [diff] [blame] | 132 | 	 |