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"],
|
2002-06-26 22:06:08 +00:00
|
|
|
prefixname="mwerks_shcarbon_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"])
|
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")
|
|
|
|
genpluginproject("carbon", "xxsubtype", sources=["xxsubtype.c"])
|
|
|
|
genpluginproject("carbon", "_hotshot", sources=["_hotshot.c"])
|
2000-12-03 22:31:50 +00:00
|
|
|
|
|
|
|
# bgen-generated Toolbox modules
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_AE", outputdir="::Lib:Carbon")
|
2002-09-06 22:59:00 +00:00
|
|
|
genpluginproject("carbon", "_AH", outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_App", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Cm", outputdir="::Lib:Carbon")
|
2001-12-13 13:21:38 +00:00
|
|
|
# XXX can't work properly because we need to set a custom fragment initializer
|
|
|
|
#genpluginproject("carbon", "_CG",
|
|
|
|
# sources=["_CGModule.c", "CFMLateImport.c"],
|
|
|
|
# libraries=["CGStubLib"],
|
|
|
|
# outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_Ctl", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Dlg", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Drag", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Evt",
|
2002-03-24 22:59:16 +00:00
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_File",
|
2002-03-24 22:59:16 +00:00
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Fm",
|
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Folder",
|
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Help", outputdir="::Lib:Carbon")
|
2002-08-05 14:12:24 +00:00
|
|
|
genpluginproject("carbon", "_IBCarbon", sources=[":ibcarbon:_IBCarbon.c"],
|
|
|
|
outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_Icn", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_List", outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_Menu", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Qd",
|
2002-03-24 22:59:16 +00:00
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Qt",
|
|
|
|
libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Qdoffs",
|
2002-03-24 22:59:16 +00:00
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Res",
|
2002-03-22 14:15:07 +00:00
|
|
|
stdlibraryflags="Debug, WeakImport", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Scrap", outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_Snd", outputdir="::Lib:Carbon")
|
2002-12-13 23:34:03 +00:00
|
|
|
genpluginproject("carbon", "_Sndihooks", sources=[":snd:_Sndihooks.c"], outputdir="::Lib:Carbon")
|
2001-08-23 13:51:46 +00:00
|
|
|
genpluginproject("carbon", "_TE", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Mlte", outputdir="::Lib:Carbon")
|
|
|
|
genpluginproject("carbon", "_Win", outputdir="::Lib:Carbon")
|
2002-07-22 12:32:31 +00:00
|
|
|
genpluginproject("carbon", "_CF", sources=["_CFmodule.c", "pycfbridge.c"], outputdir="::Lib:Carbon")
|
2001-12-12 22:42:37 +00:00
|
|
|
genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon")
|
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
|
|
|
|