| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | import mkcwproject | 
					
						
							|  |  |  | import sys | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
										
										
											2001-01-03 16:44:56 +00:00
										 |  |  | import string | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | PROJECTDIR = os.path.join(sys.prefix, ":Mac:Build") | 
					
						
							|  |  |  | MODULEDIRS = [	# Relative to projectdirs | 
					
						
							|  |  |  | 	"::Modules:%s", | 
					
						
							|  |  |  | 	"::Modules", | 
					
						
							|  |  |  | 	":::Modules", | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | # Global variable to control forced rebuild (otherwise the project is only rebuilt | 
					
						
							|  |  |  | # when it is changed) | 
					
						
							|  |  |  | FORCEREBUILD=0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-03 16:44:56 +00:00
										 |  |  | def relpath(base, path): | 
					
						
							|  |  |  | 	"""Turn abs path into path relative to another. Only works for 2 abs paths
 | 
					
						
							|  |  |  | 	both pointing to folders"""
 | 
					
						
							|  |  |  | 	if not os.path.isabs(base) or not os.path.isabs(path): | 
					
						
							|  |  |  | 		raise 'Absolute paths only' | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 	if base[-1] == ':': | 
					
						
							|  |  |  | 		base = base[:-1] | 
					
						
							| 
									
										
										
										
											2001-01-03 16:44:56 +00:00
										 |  |  | 	basefields = string.split(base, os.sep) | 
					
						
							|  |  |  | 	pathfields = string.split(path, os.sep) | 
					
						
							|  |  |  | 	commonfields = len(os.path.commonprefix((basefields, pathfields))) | 
					
						
							|  |  |  | 	basefields = basefields[commonfields:] | 
					
						
							|  |  |  | 	pathfields = pathfields[commonfields:] | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 	pathfields = ['']*(len(basefields)+1) + pathfields | 
					
						
							|  |  |  | 	rv = string.join(pathfields, os.sep) | 
					
						
							|  |  |  | 	return rv | 
					
						
							| 
									
										
										
										
											2001-01-03 16:44:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | def genpluginproject(architecture, module, | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		project=None, projectdir=None, | 
					
						
							|  |  |  | 		sources=[], sourcedirs=[], | 
					
						
							|  |  |  | 		libraries=[], extradirs=[], | 
					
						
							|  |  |  | 		extraexportsymbols=[]): | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	if architecture == "all": | 
					
						
							|  |  |  | 		# For the time being we generate two project files. Not as nice as | 
					
						
							|  |  |  | 		# a single multitarget project, but easier to implement for now. | 
					
						
							|  |  |  | 		genpluginproject("ppc", module, project, projectdir, sources, sourcedirs, | 
					
						
							|  |  |  | 				libraries, extradirs, extraexportsymbols) | 
					
						
							|  |  |  | 		genpluginproject("carbon", module, project, projectdir, sources, sourcedirs, | 
					
						
							|  |  |  | 				libraries, extradirs, extraexportsymbols) | 
					
						
							|  |  |  | 		return | 
					
						
							|  |  |  | 	templatename = "template-%s" % architecture | 
					
						
							|  |  |  | 	targetname = "%s.%s" % (module, architecture) | 
					
						
							|  |  |  | 	dllname = "%s.%s.slb" % (module, architecture) | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	if not project: | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 		if architecture != "ppc": | 
					
						
							|  |  |  | 			project = "%s.%s.mcp"%(module, architecture) | 
					
						
							|  |  |  | 		else: | 
					
						
							|  |  |  | 			project = "%s.mcp"%module | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	if not projectdir: | 
					
						
							|  |  |  | 		projectdir = PROJECTDIR | 
					
						
							|  |  |  | 	if not sources: | 
					
						
							|  |  |  | 		sources = [module + 'module.c'] | 
					
						
							|  |  |  | 	if not sourcedirs: | 
					
						
							|  |  |  | 		for moduledir in MODULEDIRS: | 
					
						
							|  |  |  | 			if '%' in moduledir: | 
					
						
							|  |  |  | 				moduledir = moduledir % module | 
					
						
							|  |  |  | 			fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) | 
					
						
							|  |  |  | 			if os.path.exists(fn): | 
					
						
							|  |  |  | 				moduledir, sourcefile = os.path.split(fn) | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 				sourcedirs = [relpath(projectdir, moduledir)] | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 				sources[0] = sourcefile | 
					
						
							|  |  |  | 				break | 
					
						
							|  |  |  | 		else: | 
					
						
							|  |  |  | 			print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) | 
					
						
							|  |  |  | 			sourcedirs = [] | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	if architecture == "carbon": | 
					
						
							|  |  |  | 		prefixname = "mwerks_carbonplugin_config.h" | 
					
						
							|  |  |  | 	else: | 
					
						
							|  |  |  | 		prefixname = "mwerks_plugin_config.h" | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	dict = { | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 		"sysprefix" : relpath(projectdir, sys.prefix), | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		"sources" : sources, | 
					
						
							|  |  |  | 		"extrasearchdirs" : sourcedirs + extradirs, | 
					
						
							|  |  |  | 		"libraries": libraries, | 
					
						
							| 
									
										
										
										
											2001-01-03 16:44:56 +00:00
										 |  |  | 		"mac_outputdir" : "::Plugins", | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		"extraexportsymbols" : extraexportsymbols, | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 		"mac_targetname" : targetname, | 
					
						
							|  |  |  | 		"mac_dllname" : dllname, | 
					
						
							|  |  |  | 		"prefixname" : prefixname, | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	mkcwproject.mkproject(os.path.join(projectdir, project), module, dict,  | 
					
						
							|  |  |  | 			force=FORCEREBUILD, templatename=templatename) | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | def	genallprojects(force=0): | 
					
						
							|  |  |  | 	global FORCEREBUILD | 
					
						
							|  |  |  | 	FORCEREBUILD = force | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	# Standard Python modules | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("all", "pyexpat",  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		sources=["pyexpat.c"],  | 
					
						
							|  |  |  | 		libraries=["libexpat.ppc.lib"],  | 
					
						
							| 
									
										
										
										
											2000-12-29 16:07:30 +00:00
										 |  |  | 		extradirs=["::::expat:*"]) | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("all", "zlib",  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		libraries=["zlib.ppc.Lib"],  | 
					
						
							|  |  |  | 		extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("all", "gdbm",  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		libraries=["gdbm.ppc.gusi.lib"],  | 
					
						
							|  |  |  | 		extradirs=["::::gdbm:mac", "::::gdbm"]) | 
					
						
							| 
									
										
										
										
											2001-02-12 14:50:52 +00:00
										 |  |  | 	genpluginproject("all", "_weakref", sources=["_weakref.c"]) | 
					
						
							|  |  |  | 	genpluginproject("all", "_symtable", sources=["symtablemodule.c"]) | 
					
						
							|  |  |  | 	genpluginproject("all", "_testcapi") | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	# bgen-generated Toolbox modules | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("ppc", "App", libraries=["AppearanceLib"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "App") | 
					
						
							| 
									
										
										
										
											2001-05-17 22:12:55 +00:00
										 |  |  | ##	genpluginproject("ppc", "Cm", | 
					
						
							|  |  |  | ##		libraries=["QuickTimeLib"], | 
					
						
							|  |  |  | ##		extraexportsymbols=[ | 
					
						
							|  |  |  | ##			"CmpObj_New", | 
					
						
							|  |  |  | ##			"CmpObj_Convert", | 
					
						
							|  |  |  | ##			"CmpInstObj_New", | 
					
						
							|  |  |  | ##			"CmpInstObj_Convert", | 
					
						
							|  |  |  | ##		]) | 
					
						
							|  |  |  | ##	genpluginproject("carbon", "Cm", | 
					
						
							|  |  |  | ##		extraexportsymbols=[ | 
					
						
							|  |  |  | ##			"CmpObj_New", | 
					
						
							|  |  |  | ##			"CmpObj_Convert", | 
					
						
							|  |  |  | ##			"CmpInstObj_New", | 
					
						
							|  |  |  | ##			"CmpInstObj_Convert", | 
					
						
							|  |  |  | ##		]) | 
					
						
							|  |  |  | 	genpluginproject("ppc", "Cm", libraries=["QuickTimeLib"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "Cm") | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("all", "Fm") | 
					
						
							|  |  |  | 	genpluginproject("ppc", "Help") | 
					
						
							|  |  |  | 	genpluginproject("ppc", "Icn", libraries=["IconServicesLib"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "Icn") | 
					
						
							|  |  |  | 	genpluginproject("all", "List") | 
					
						
							| 
									
										
										
										
											2001-05-17 22:12:55 +00:00
										 |  |  | ##	genpluginproject("ppc", "Qt", libraries=["QuickTimeLib", "Cm.ppc.slb", "Qdoffs.ppc.slb"],  | 
					
						
							|  |  |  | ##			extradirs=["::Plugins"]) | 
					
						
							|  |  |  | 	genpluginproject("ppc", "Qt", libraries=["QuickTimeLib"]) | 
					
						
							|  |  |  | ##	genpluginproject("carbon", "Qt", libraries=["Cm.carbon.slb", "Qdoffs.carbon.slb"], | 
					
						
							|  |  |  | ##			extradirs=["::Plugins"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "Qt") | 
					
						
							|  |  |  | ##	genpluginproject("all", "Qdoffs", | 
					
						
							|  |  |  | ##		extraexportsymbols=["GWorldObj_New", "GWorldObj_Convert"]) | 
					
						
							|  |  |  | 	genpluginproject("all", "Qdoffs") | 
					
						
							| 
									
										
										
										
											2001-01-24 16:02:07 +00:00
										 |  |  | 	genpluginproject("all", "Scrap") | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("ppc", "Snd", libraries=["SoundLib"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "Snd") | 
					
						
							|  |  |  | 	genpluginproject("all", "Sndihooks", sources=[":snd:Sndihooks.c"]) | 
					
						
							|  |  |  | 	genpluginproject("ppc", "TE", libraries=["DragLib"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "TE") | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-06-26 21:52:08 +00:00
										 |  |  | 	# OSX Only? | 
					
						
							|  |  |  | 	genpluginproject("carbon", "CF") | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	# Other Mac modules | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("all", "calldll", sources=["calldll.c"]) | 
					
						
							|  |  |  | 	genpluginproject("all", "ColorPicker") | 
					
						
							|  |  |  | 	genpluginproject("ppc", "Printing") | 
					
						
							|  |  |  | 	genpluginproject("ppc", "waste", | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		sources=[ | 
					
						
							|  |  |  | 			"wastemodule.c", | 
					
						
							|  |  |  | 			'WEAccessors.c', 'WEBirthDeath.c', 'WEDebug.c', | 
					
						
							|  |  |  | 			'WEDrawing.c', 'WEFontTables.c', 'WEHighLevelEditing.c', | 
					
						
							|  |  |  | 			'WEICGlue.c', 'WEInlineInput.c', 'WELineLayout.c', 'WELongCoords.c', | 
					
						
							|  |  |  | 			'WELowLevelEditing.c', 'WEMouse.c', 'WEObjects.c', 'WEScraps.c', | 
					
						
							|  |  |  | 			'WESelecting.c', 'WESelectors.c', 'WEUserSelectors.c', 'WEUtilities.c', | 
					
						
							|  |  |  | 			'WEObjectHandlers.c', | 
					
						
							|  |  |  | 			'WETabs.c', | 
					
						
							|  |  |  | 			'WETabHooks.c'], | 
					
						
							|  |  |  | 		libraries=['DragLib'], | 
					
						
							| 
									
										
										
										
											2001-01-22 14:50:05 +00:00
										 |  |  | 		extradirs=[ | 
					
						
							|  |  |  | 			'::::Waste 1.3 Distribution:*', | 
					
						
							|  |  |  | 			'::::ICProgKit1.4:APIs'] | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		) | 
					
						
							| 
									
										
										
										
											2001-01-24 16:02:07 +00:00
										 |  |  | 	# This is a hack, combining parts of Waste 2.0 with parts of 1.3 | 
					
						
							|  |  |  | 	genpluginproject("carbon", "waste", | 
					
						
							|  |  |  | 		sources=[ | 
					
						
							|  |  |  | 			"wastemodule.c", | 
					
						
							|  |  |  | 			"WEObjectHandlers.c", | 
					
						
							|  |  |  | 			"WETabs.c", "WETabHooks.c"], | 
					
						
							|  |  |  | 		libraries=["WASTE.Carbon.lib"], | 
					
						
							|  |  |  | 		extradirs=[ | 
					
						
							|  |  |  | 			'{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:C_C++ Headers', | 
					
						
							|  |  |  | 			'{Compiler}:MacOS Support:(Third Party Support):Waste 2.0 Distribution:Static Libraries', | 
					
						
							|  |  |  | 			'::::Waste 1.3 Distribution:Extras:Sample Object Handlers', | 
					
						
							|  |  |  | 			'::::Waste 1.3 Distribution:Extras:Waste Tabs 1.3.2'] | 
					
						
							|  |  |  | 		) | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("ppc", "ctb") | 
					
						
							|  |  |  | 	genpluginproject("ppc", "icglue", sources=["icgluemodule.c"],  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		libraries=["ICGlueCFM-PPC.lib"],  | 
					
						
							|  |  |  | 		extradirs=["::::ICProgKit1.4:APIs"]) | 
					
						
							| 
									
										
										
										
											2001-01-29 13:27:46 +00:00
										 |  |  | 	genpluginproject("carbon", "icglue", sources=["icgluemodule.c"],  | 
					
						
							|  |  |  | 		extradirs=["::::ICProgKit1.4:APIs"]) | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	genpluginproject("ppc", "macspeech", libraries=["SpeechLib"]) | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  | 	genallprojects() | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 	 |