Added a force option (to force project generation, the default is now to only generate if different).

Try to convert all search paths to relative.
This commit is contained in:
Jack Jansen 2001-01-21 22:24:27 +00:00
parent d6389956cb
commit 1eda203a02
1 changed files with 16 additions and 10 deletions

View File

@ -10,22 +10,25 @@ MODULEDIRS = [ # Relative to projectdirs
":::Modules", ":::Modules",
] ]
# Global variable to control forced rebuild (otherwise the project is only rebuilt
# when it is changed)
FORCEREBUILD=0
def relpath(base, path): def relpath(base, path):
"""Turn abs path into path relative to another. Only works for 2 abs paths """Turn abs path into path relative to another. Only works for 2 abs paths
both pointing to folders""" both pointing to folders"""
if not os.path.isabs(base) or not os.path.isabs(path): if not os.path.isabs(base) or not os.path.isabs(path):
raise 'Absolute paths only' raise 'Absolute paths only'
if base[-1] != ':': if base[-1] == ':':
base = base +':' base = base[:-1]
if path[-1] != ':':
path = path + ':'
basefields = string.split(base, os.sep) basefields = string.split(base, os.sep)
pathfields = string.split(path, os.sep) pathfields = string.split(path, os.sep)
commonfields = len(os.path.commonprefix((basefields, pathfields))) commonfields = len(os.path.commonprefix((basefields, pathfields)))
basefields = basefields[commonfields:] basefields = basefields[commonfields:]
pathfields = pathfields[commonfields:] pathfields = pathfields[commonfields:]
pathfields = ['']*len(basefields) + pathfields pathfields = ['']*(len(basefields)+1) + pathfields
return string.join(pathfields, os.sep) rv = string.join(pathfields, os.sep)
return rv
def genpluginproject(module, def genpluginproject(module,
project=None, projectdir=None, project=None, projectdir=None,
@ -45,23 +48,25 @@ def genpluginproject(module,
fn = os.path.join(projectdir, os.path.join(moduledir, sources[0])) fn = os.path.join(projectdir, os.path.join(moduledir, sources[0]))
if os.path.exists(fn): if os.path.exists(fn):
moduledir, sourcefile = os.path.split(fn) moduledir, sourcefile = os.path.split(fn)
sourcedirs = [moduledir] sourcedirs = [relpath(projectdir, moduledir)]
sources[0] = sourcefile sources[0] = sourcefile
break break
else: else:
print "Warning: %s: sourcefile not found: %s"%(module, sources[0]) print "Warning: %s: sourcefile not found: %s"%(module, sources[0])
sourcedirs = [] sourcedirs = []
dict = { dict = {
"sysprefix" : sys.prefix, "sysprefix" : relpath(projectdir, sys.prefix),
"sources" : sources, "sources" : sources,
"extrasearchdirs" : sourcedirs + extradirs, "extrasearchdirs" : sourcedirs + extradirs,
"libraries": libraries, "libraries": libraries,
"mac_outputdir" : "::Plugins", "mac_outputdir" : "::Plugins",
"extraexportsymbols" : extraexportsymbols, "extraexportsymbols" : extraexportsymbols,
} }
mkcwproject.mkproject(os.path.join(projectdir, project), module, dict) mkcwproject.mkproject(os.path.join(projectdir, project), module, dict, force=FORCEREBUILD)
def genallprojects(): def genallprojects(force=0):
global FORCEREBUILD
FORCEREBUILD = force
# Standard Python modules # Standard Python modules
genpluginproject("ucnhash", sources=["ucnhash.c"]) genpluginproject("ucnhash", sources=["ucnhash.c"])
genpluginproject("pyexpat", genpluginproject("pyexpat",
@ -124,3 +129,4 @@ def genallprojects():
if __name__ == '__main__': if __name__ == '__main__':
genallprojects() genallprojects()