| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-16 20:39:17 +00:00
										 |  |  | PYTHONDIR = sys.prefix | 
					
						
							|  |  |  | PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build") | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 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=[], | 
					
						
							| 
									
										
										
										
											2001-11-30 14:16:36 +00:00
										 |  |  | 		extraexportsymbols=[], outputdir=":::Lib:lib-dynload", | 
					
						
							| 
									
										
										
										
											2002-05-23 22:34:18 +00:00
										 |  |  | 		libraryflags=None, stdlibraryflags=None, prefixname=None, | 
					
						
							|  |  |  | 		initialize=None): | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	if architecture != "carbon": | 
					
						
							|  |  |  | 		raise 'Unsupported architecture: %s'%architecture | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	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: | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 		project = "%s.%s.mcp"%(module, architecture) | 
					
						
							| 
									
										
										
										
											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: | 
					
						
							| 
									
										
										
										
											2001-08-23 13:51:46 +00:00
										 |  |  | 				# For historical reasons an initial _ in the modulename | 
					
						
							|  |  |  | 				# is not reflected in the folder name | 
					
						
							|  |  |  | 				if module[0] == '_': | 
					
						
							|  |  |  | 					modulewithout_ = module[1:] | 
					
						
							|  |  |  | 				else: | 
					
						
							|  |  |  | 					modulewithout_ = module | 
					
						
							|  |  |  | 				moduledir = moduledir % modulewithout_ | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 			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 = [] | 
					
						
							| 
									
										
										
										
											2002-03-14 23:14:43 +00:00
										 |  |  | 	if prefixname: | 
					
						
							|  |  |  | 		pass | 
					
						
							|  |  |  | 	elif architecture == "carbon": | 
					
						
							| 
									
										
										
										
											2002-06-26 22:06:08 +00:00
										 |  |  | 		prefixname = "mwerks_shcarbon_pch" | 
					
						
							| 
									
										
										
										
											2001-01-23 22:36:26 +00:00
										 |  |  | 	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-08-19 22:29:57 +00:00
										 |  |  | 		"mac_outputdir" : outputdir, | 
					
						
							| 
									
										
										
										
											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-11-30 14:16:36 +00:00
										 |  |  | 	if libraryflags: | 
					
						
							|  |  |  | 		dict['libraryflags'] = libraryflags | 
					
						
							|  |  |  | 	if stdlibraryflags: | 
					
						
							|  |  |  | 		dict['stdlibraryflags'] = stdlibraryflags | 
					
						
							| 
									
										
										
										
											2002-05-23 22:34:18 +00:00
										 |  |  | 	if initialize: | 
					
						
							|  |  |  | 		dict['initialize'] = initialize | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2002-03-14 23:14:43 +00:00
										 |  |  | 	genpluginproject("carbon", "pyexpat",  | 
					
						
							|  |  |  | 		sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], | 
					
						
							|  |  |  | 		extradirs=[":::Modules:expat"], | 
					
						
							| 
									
										
										
										
											2003-02-21 22:33:55 +00:00
										 |  |  | 		prefixname="mwerks_pyexpat_config.h" | 
					
						
							| 
									
										
										
										
											2002-03-14 23:14:43 +00:00
										 |  |  | 		) | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "zlib",  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		libraries=["zlib.ppc.Lib"],  | 
					
						
							|  |  |  | 		extradirs=["::::imglibs:zlib:mac", "::::imglibs:zlib"]) | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "gdbm",  | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 		libraries=["gdbm.ppc.gusi.lib"],  | 
					
						
							|  |  |  | 		extradirs=["::::gdbm:mac", "::::gdbm"]) | 
					
						
							| 
									
										
										
										
											2003-03-21 12:56:27 +00:00
										 |  |  | 	genpluginproject("carbon", "_csv", sources=["_csv.c"]) | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_weakref", sources=["_weakref.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_symtable", sources=["symtablemodule.c"]) | 
					
						
							| 
									
										
										
										
											2001-08-29 22:08:06 +00:00
										 |  |  | 	# Example/test modules | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_testcapi") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "xx") | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 	genpluginproject("carbon", "datetime") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "xxsubtype", sources=["xxsubtype.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_hotshot", sources=["_hotshot.c"]) | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	# bgen-generated Toolbox modules | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 	genpluginproject("carbon", "_AE") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_AH") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_App") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Cm") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Ctl") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Dlg") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Drag") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Evt",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_File",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Fm",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Folder",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Help") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_IBCarbon", sources=[":ibcarbon:_IBCarbon.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Icn") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_List") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Menu") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Qd",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-03-24 22:59:16 +00:00
										 |  |  | 	genpluginproject("carbon", "_Qt",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			libraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Qdoffs",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "_Res",  | 
					
						
							| 
									
										
										
										
											2003-01-08 16:27:44 +00:00
										 |  |  | 			stdlibraryflags="Debug, WeakImport") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Scrap") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Snd") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Sndihooks", sources=[":snd:_Sndihooks.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_TE") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Mlte") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_Win") | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_CF", sources=["_CFmodule.c", "pycfbridge.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "_CarbonEvt") | 
					
						
							| 
									
										
										
										
											2001-11-06 15:56:56 +00:00
										 |  |  | 	genpluginproject("carbon", "hfsplus") | 
					
						
							| 
									
										
										
										
											2001-06-26 21:52:08 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 	# Other Mac modules | 
					
						
							| 
									
										
										
										
											2002-12-13 23:34:03 +00:00
										 |  |  | 	genpluginproject("carbon", "calldll", sources=["calldll.c"]) | 
					
						
							|  |  |  | 	genpluginproject("carbon", "ColorPicker") | 
					
						
							| 
									
										
										
										
											2001-01-24 16:02:07 +00:00
										 |  |  | 	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', | 
					
						
							| 
									
										
										
										
											2002-01-11 12:39:03 +00:00
										 |  |  | 			'::wastemods', | 
					
						
							|  |  |  | 			] | 
					
						
							| 
									
										
										
										
											2001-01-24 16:02:07 +00:00
										 |  |  | 		) | 
					
						
							| 
									
										
										
										
											2002-01-11 12:39:03 +00:00
										 |  |  | 	genpluginproject("carbon", "icglue", sources=["icgluemodule.c"]) | 
					
						
							| 
									
										
										
										
											2000-12-03 22:31:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  | 	genallprojects() | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-01-21 22:24:27 +00:00
										 |  |  | 	 |