1
import SCons.Util, SCons.Scanner
7
"""Change the cxx parts of env for the Darwin platform"""
8
env["CXXFLAGS"] += " -undefined dynamic_lookup"
9
env["SHLINKFLAGS"] += " -undefined dynamic_lookup"
10
env["LDMODULEFLAGS"] += " -undefined dynamic_lookup"
11
if not env.GetOption("clean"):
12
# remove /usr/lib if present in LIBPATH.
13
# there should maybe be some testing here to make sure
14
# it doesn't blow in our face.
16
env["LIBPATH"].remove('/usr/lib')
22
"""Change the swig parts of env for the Darwin platform"""
23
env['SHLINKFLAGS'] = env['LDMODULEFLAGS']
24
env['SHLINKCOM'] = env['LDMODULECOM']
25
env["SHLIBSUFFIX"] = ".so"
29
def swigScanner(node, env, path):
30
"""SCons scanner hook to scan swig files for dependencies.
31
@return: list of files depended on.
33
include_pattern = re.compile(r"%include\s+(\S+)")
35
def recurse(path, search_path):
36
"""Scan recursively."""
38
try: contents = f.read()
42
for m in include_pattern.finditer(contents):
43
inc_fpath = m.group(1)
45
inc_fpath = inc_fpath.strip("'").strip('"')
46
# Strip off site include marks
47
inc_fpath = inc_fpath.strip('<').strip('>')
48
real_fpath = os.path.realpath(inc_fpath)
49
if os.path.dirname(real_fpath) != os.path.dirname(path):
50
# Not in same directory as original swig file
51
if os.path.isfile(real_fpath):
52
found.append(real_fpath)
55
# Look for unqualified filename on path
56
for dpath in search_path:
57
abs_path = os.path.join(dpath, inc_fpath)
58
if os.path.isfile(abs_path):
59
found.append(abs_path)
62
for f in [f for f in found if os.path.splitext(f)[1] == ".i"]:
63
found += recurse(f, search_path)
66
fpath = node.srcnode().path
67
search_path = [os.path.abspath(d) for d in re.findall(r"-I(\S+)", " ".join(env["SWIGFLAGS"]))]
68
search_path.insert(0, os.path.abspath(os.path.dirname(fpath)))
69
r = recurse(fpath, search_path)
72
swigscanner = SCons.Scanner.Scanner(function=swigScanner, skeys=[".i"])
74
def swigEmitter(target, source, env):
77
if "-python" in SCons.Util.CLVar(env.subst("$SWIGFLAGS")):
78
target.append(os.path.splitext(src)[0] + ".py")
79
return (target, source)
83
def __init__(self, cppPath=None, libPath=None, libs=None, linkOpts=None, version=None, compiler=None):
84
self.cppPath, self.libPath, self.libs, self.linkOpts, self.version, self.compiler = cppPath, libPath, libs, linkOpts, version, compiler
87
return "\ncppPath: %s\nlibPath: %s\nlibs: %s\nlibs: %s\ncompiler: %s\n" % \
88
(self.cppPath,self.libPath,self.libs,self.linkOpts,self.compiler)