def CythonGenerate(e, pyx, h=None, c=None, incdirs=[], cpp=False): cython = excons.GetArgument("with-cython", "") if not cython: cython = "cython%s" % Version() path = excons.Which(cython) if path is None: excons.PrintOnce("No \"%s\" found in PATH. Try with \"cython\" instead" % cython, tool="python") cython = "cython" path = excons.Which(cython) if path is None: excons.PrintOnce("Cannot find a valid cython in your PATH, use with-cython= flag to provide a valid location.", tool="python") sys.exit(1) excons.PrintOnce("Use \"%s\" found in %s." % (cython, path), tool="python") if h is None: h = os.path.splitext(pyx)[0] + ".h" if c is None: c = os.path.splitext(pyx)[0] + (".cpp" if cpp else ".c") cmd = cython + " " + " ".join(map(lambda x: "-I %s" % x, incdirs)) + (" --cplus" if cpp else "") + " --embed-positions -o $TARGET $SOURCE" # Command seems to fail if PATH and PYTHONPATH are not set ec = e.Clone() ec["ENV"]["PATH"] = os.environ.get("PATH", "") ec["ENV"]["PYTHONPATH"] = os.environ.get("PYTHONPATH", "") return ec.Command([c, h], pyx, cmd)
def _RealRequire(env): quiet, cfg = GetConf(env, hdf5_inc) if hdf5_inc: env.Append(CPPPATH=[hdf5_inc]) if hdf5_lib: env.Append(LIBPATH=[hdf5_lib]) if hl: excons.Link(env, hdf5hl_libname, static=hdf5_static, force=True, silent=True) excons.Link(env, hdf5_libname, static=hdf5_static, force=True, silent=True) if hdf5_static: if not quiet: excons.PrintOnce("Static build", tool="hdf5") if cfg["threadsafe"]: threads.Require(env) if cfg["zlib"]: if excons.GetArgument("zlib-static", None) is None: if not quiet: excons.PrintOnce("Force static zlib", tool="hdf5") excons.SetArgument("zlib-static", 1) zlib.Require(env) if cfg["szip"]: if excons.GetArgument("szip-static", None) is None: if not quiet: excons.PrintOnce("Force static szip", tool="hdf5") excons.SetArgument("szip-static", 1) szip.Require(env)
def RequireCython(e): global _cython cython = excons.GetArgument("with-cython", _cython) if not os.path.isfile(cython): excons.PrintOnce("Invalid 'cython' specification", tool="python") cython = None if not cython: cython = "cython%s" % Version() path = excons.Which(cython) if path is None: excons.PrintOnce( "No \"%s\" found in PATH. Try with \"cython\" instead" % cython, tool="python") cython = "cython" path = excons.Which(cython) if path is None: excons.PrintOnce( "Cannot find a valid cython in your PATH, use with-cython= flag to provide a valid location.", tool="python") return False excons.PrintOnce("Use \"%s\" found in %s." % (cython, path), tool="python") _cython = cython cython_include_re = re.compile(r"^include\s+([\"'])(\S+)\1", re.MULTILINE) def scan_cython_includes(node, env, path): if hasattr(node, "get_text_contents"): lst = [ m[1] for m in cython_include_re.findall(node.get_text_contents()) ] return lst elif hasattr(node, "get_contents"): lst = [ m[1] for m in cython_include_re.findall(str(node.get_contents())) ] return lst else: return [] e.Append(SCANNERS=SCons.Script.Scanner(function=scan_cython_includes, skeys=".pyx")) return True
def ExternalLibRequire(configOpts, name, libnameFunc=None, definesFunc=None, extraEnvFunc=None, varPrefix=None): rv = excons.ExternalLibRequire(name, libnameFunc=libnameFunc, definesFunc=definesFunc, extraEnvFunc=extraEnvFunc) req = rv["require"] if req is not None: defines = ("" if definesFunc is None else definesFunc(rv["static"])) if defines: extraflags = " ".join(map(lambda x: "-D%s" % x, defines)) configOpts["CMAKE_CPP_FLAGS"] = "%s %s" % (configOpts.get( "CMAKE_CPP_FLAGS", ""), extraflags) if varPrefix is None: varPrefix = name.upper() + "_" excons.PrintOnce( "Use CMake variable prefix '%s' for external dependency '%s'" % (varPrefix, name)) configOpts["%sINCLUDE_DIR" % varPrefix] = rv["incdir"] configOpts["%sLIBRARY" % varPrefix] = rv["libpath"] # sometimes LIBRARY is used, sometines LIBRARY_RELEASE / LIBRARY_DEBUG... configOpts["%sLIBRARY_DEBUG" % varPrefix] = rv["libpath"] configOpts["%sLIBRARY_RELEASE" % varPrefix] = rv["libpath"] return rv
def ExternalLibRequire(configOpts, name, libnameFunc=None, definesFunc=None, extraEnvFunc=None, flagName=None): rv = excons.ExternalLibRequire(name, libnameFunc=libnameFunc, definesFunc=definesFunc, extraEnvFunc=extraEnvFunc) req = rv["require"] if req is not None: defines = ("" if definesFunc is None else definesFunc(rv["static"])) if defines: extraflags = " ".join(map(lambda x: "-D%s" % x, defines)) configOpts["CPPFLAGS"] = "%s %s" % (os.environ.get("CPPFLAGS", ""), extraflags) if flagName is None: flagName = name excons.PrintOnce( "Use Automake flag '%s' for external dependency '%s'" % (flagName, name)) configOpts["--with-%s" % flag] = "%s,%s" % (rv["incdir"], rv["libdir"]) return rv
def CythonGenerate(e, pyx, h=None, c=None, incdirs=[], cpp=False, cte={}, directives={}): global _cython if float(Version()) < 3: directives["language_level"] = 2 if not _cython: excons.PrintOnce("No 'cython' to generate %s" % pyx, tool="python") return None if h is None: h = os.path.splitext(pyx)[0] + ".h" if c is None: c = os.path.splitext(pyx)[0] + (".cpp" if cpp else ".c") cteflags = "".join([" -E %s=%s" % (k, v) for k, v in cte.items()]) dirflags = "".join( [" --directive %s=%s" % (k, v) for k, v in directives.items()]) cmd = _cython + " " + " ".join(map(lambda x: "-I %s" % x, incdirs)) + ( " --cplus" if cpp else "") + cteflags + dirflags + " --embed-positions -o $TARGET $SOURCE" # Command seems to fail if PATH and PYTHONPATH are not set ec = e.Clone() ec["ENV"]["PATH"] = os.environ.get("PATH", "") ec["ENV"]["PYTHONPATH"] = os.environ.get("PYTHONPATH", "") return ec.Command([c, h], pyx, cmd)
def GetMayaRoot(noWarn=False): mayaspec = excons.GetArgument("with-maya") if "MAYA_LOCATION" in os.environ: if not "with-maya" in SCons.Script.ARGUMENTS: # MAYA_LOCATION environment is set and with-maya is either undefined or read from cache excons.PrintOnce("Using MAYA_LOCATION environment.", tool="maya") mayadir = os.environ["MAYA_LOCATION"] return mayadir else: excons.PrintOnce("Ignoring MAYA_LOCATION environment.", tool="maya") if not mayaspec: if not noWarn: #excons.WarnOnce("Please set Maya version or directory using with-maya=", tool="maya") excons.WarnConfig() return None if not os.path.isdir(mayaspec): if not re.match(r"\d+(\.\d+)?", mayaspec): if not noWarn: excons.WarnOnce( "Invalid Maya specification \"%s\": Must be a directory or a version number" % mayaspec, tool="maya") return None ver = mayaspec if sys.platform == "win32": if excons.arch_dir == "x64": mayadir = "C:/Program Files/Autodesk/Maya%s" % ver else: mayadir = "C:/Program Files (x86)/Autodesk/Maya%s" % ver elif sys.platform == "darwin": mayadir = "/Applications/Autodesk/maya%s" % ver else: mayadir = "/usr/autodesk/maya%s" % ver if excons.arch_dir == "x64" and os.path.isdir(mayadir + "-x64"): mayadir += "-x64" else: mayadir = mayaspec.replace("\\", "/") if len(mayadir) > 0 and mayadir[-1] == "/": mayadir = mayadir[:-1] return mayadir
def GetMayaInc(mayadir): # Starting maya 2016, the base install doesn't come with include files require_mdk = False if sys.platform == "darwin": require_mdk = not os.path.isdir(mayadir + "/devkit/include/maya") else: require_mdk = not os.path.isdir(mayadir + "/include/maya") mdk = (None if not require_mdk else excons.GetArgument("with-mayadevkit")) if "MAYA_INCLUDE" in os.environ: if not require_mdk or "with-mayadevkit" not in SCons.Script.ARGUMENTS: # MAYA_INCLUDE environment is set and maya is older than 2016 or with-mayadevkit is either undefined or read from cache excons.PrintOnce("Using MAYA_INCLUDE environment.", tool="maya") mayainc = os.environ["MAYA_INCLUDE"] return mayainc else: excons.PrintOnce("Ignoring MAYA_INCLUDE environment.", tool="maya") if mdk is None: if sys.platform == "darwin": mayainc = mayadir + "/devkit/include" else: mayainc = mayadir + "/include" else: mdk = mdk.replace("\\", "/") if len(mdk) > 0 and mdk[-1] == "/": mdk = mdk[:-1] if os.path.isabs(mdk): mayainc = mdk + "/include" else: mayainc = mayadir + "/" + mdk + "/include" return mayainc
def _RealRequire(env): global ThreadSafe_exp, Szlib_exp, Zlib_exp, hdf5_confs hdf5_inc, hdf5_lib = excons.GetDirs("hdf5") if hdf5_inc: env.Append(CPPPATH=[hdf5_inc]) if hdf5_lib: env.Append(LIBPATH=[hdf5_lib]) hdf5_libname = excons.GetArgument("hdf5-libname", None) if not hdf5_libname: hdf5_libsuffix = excons.GetArgument("hdf5-libsuffix", "") hdf5_basename = ("hdf5" if sys.platform != "win32" else "libhdf5") hdf5_libname = hdf5_basename + hdf5_libsuffix hdf5hl_libname = hdf5_basename + "_hl" + hdf5_libsuffix else: hdf5hl_libname = hdf5_libname + "_hl" if hl: env.Append(LIBS=[hdf5hl_libname, hdf5_libname]) else: env.Append(LIBS=[hdf5_libname]) hdf5_static = (excons.GetArgument("hdf5-static", 0, int) != 0) hdf5_threadsafe = False hdf5_szip = False hdf5_zlib = False h5conf = None if hdf5_inc: # Note: On Fedora 14, H5pubconf.h has been renamed to H5pubconf-64.h # -> be slightly more flexible when looking up this file lst = filter(lambda x: os.path.basename(x).startswith("H5pubconf"), glob.glob(hdf5_inc + "/*.h")) if len(lst) > 0: h5conf = lst[0].replace("\\", "/") else: # Look in current include paths for d in env["CPPPATH"]: lst = filter( lambda x: os.path.basename(x).startswith("H5pubconf"), glob.glob(d + "/*.h")) if len(lst) > 0: h5conf = lst[0].replace("\\", "/") break quiet = not verbose if h5conf: if h5conf in hdf5_confs: hdf5_threadsafe = hdf5_confs[h5conf]["threadsafe"] hdf5_zlib = hdf5_confs[h5conf]["zlib"] hdf5_szip = hdf5_confs[h5conf]["szip"] quiet = True else: if verbose: excons.PrintOnce("Reading configuration header '%s'..." % h5conf, tool="hdf5") f = open(h5conf, "r") for l in f.readlines(): l = l.strip() if ThreadSafe_exp.match(l): hdf5_threadsafe = True elif Szip_exp.match(l): hdf5_szip = True elif Zlib_exp.match(l): hdf5_zlib = True hdf5_confs[h5conf] = { "threadsafe": hdf5_threadsafe, "zlib": hdf5_zlib, "szip": hdf5_szip } f.close() if not quiet: if hdf5_threadsafe: excons.PrintOnce("Thread safe", tool="hdf5") if hdf5_zlib: excons.PrintOnce("Using zlib", tool="hdf5") if hdf5_szip: excons.PrintOnce("Using szip", tool="hdf5") else: excons.WarnOnce("Could not find configuration header", tool="hdf5") if hdf5_static: if not quiet: excons.PrintOnce("Static build", tool="hdf5") if hdf5_threadsafe: threads.Require(env) if hdf5_zlib: if excons.GetArgument("zlib-static", None) is None: if not quiet: excons.PrintOnce("Force static zlib", tool="hdf5") excons.SetArgument("zlib-static", 1) zlib.Require(env) if hdf5_szip: szip_static = excons.GetArgument("szip-static", None) if szip_static is None: if not quiet: excons.PrintOnce("Force static szip", tool="hdf5") excons.SetArgument("szip-static", 1) szip.Require(env)
def _GetPythonSpec(specString): global _specCache if specString in _specCache: return _specCache[specString] spec = None specErr = "" plat = str(SCons.Script.Platform()) if re.match(r"\d+\.\d+", specString): ver = specString # Look in standard locations if plat == "darwin": searchPaths = ["/System/Library/Frameworks", "/Library/Frameworks"] for searchPath in searchPaths: pythonPath = excons.joinpath(searchPath, "Python.framework", "Versions", ver) if os.path.isdir(pythonPath): incdir = None for isd in ("include/python%s" % ver, "Headers"): _incdir = pythonPath + "/" + isd if os.path.isdir(_incdir): incdir = _incdir break if incdir is not None: if ver == _GetPythonVersionOSX( excons.joinpath(searchPath, "Python.framework")): spec = (ver, incdir, searchPath, "Python") specErr = "" break else: spec = (ver, incdir, None, "%s/Python" % (pythonPath)) specErr = "" break else: specErr += "\n Cannot find python %s include directory in %s" % ( ver, pythonPath) else: specErr += "\n Cannot find python %s in %s" % (ver, searchPath) elif plat == "win32": pythonPath = "C:\\Python%s" % ver.replace(".", "") if os.path.isdir(pythonPath): incdir = excons.joinpath(pythonPath, "include") libdir = excons.joinpath(pythonPath, "libs") lib = "python%s" % ver.replace(".", "") spec = (ver, incdir, libdir, lib) else: searchPaths = ["/usr", "/usr/local"] for searchPath in searchPaths: pythonPath = excons.joinpath(searchPath, "bin", "python%s" % ver) if not os.path.isfile(pythonPath): pythonPath = excons.joinpath(searchPath, "python") if os.path.isfile(pythonPath) and _GetPythonVersionUNIX( pythonPath) == ver: spec = (ver, searchPath) break else: spec = (ver, searchPath) break if spec: ver, prefix = spec incdir = excons.joinpath(prefix, "include", "python%s" % ver) libdir = excons.joinpath( prefix, ("lib64" if excons.Build64() else "lib")) lib = "python%s" % ver spec = (ver, incdir, libdir, lib) if spec is None: curver = str(distutils.sysconfig.get_python_version()) specErr += "\n" if curver != ver: excons.PrintOnce( "Couldn't find stock python %s.%sCurrent version doesn't match (%s), aborting build." % (ver, specErr, curver), tool="python") sys.exit(1) else: excons.PrintOnce( "Couldn't find stock python %s.%sUse currently running version instead." % (ver, specErr), tool="python") else: if plat == "darwin": if specString[-1] == "/": specString = specString[:-1] m = re.search(r"/([^/]+)\.framework/Versions/([^/]+)/?$", specString) if m: fwn = m.group(1) ver = m.group(2) fw = "%s/%s" % (specString, fwn) fwh = "%s/Headers" % specString if not os.path.isdir(fwh): fwh = "%s/include/python%s" % (specString, ver) if os.path.isfile(fw) and os.path.isdir(fwh): # if it is the current version, use framework directory fwd = re.sub(r"/Versions/.*$", "", specString) if ver == _GetPythonVersionOSX(fwd): spec = (ver, fwh, os.path.dirname(fwd), fwn) else: spec = (ver, fwh, None, fw) else: if not os.path.isfile(fwh): specErr += "\n Cannot find python %s include directory in %s" % ( ver, specString) if not os.path.isfile(fw): specErr += "\n Cannot find python framework in %s" % specString else: ver = _GetPythonVersionOSX(specString) if ver is not None: d = os.path.dirname(specString) n = os.path.splitext(os.path.basename(specString))[0] incdir = None for isd in ("include/python%s" % ver, "Headers"): _incdir = "%s/Versions/%s/%s" % (specString, ver, isd) if os.path.isdir(_incdir): incdir = _incdir break if incdir is not None: spec = (ver, incdir, d, n) else: specErr += "\n Cannot find python %s include directory in %s" % ( ver, specString) elif plat == "win32": ver = _GetPythonVersionWIN(specString) if ver is not None: d = os.path.dirname(specString) incdir = excons.joinpath(d, "include") libdir = excons.joinpath(d, "libs") lib = "python%s" % ver.replace(".", "") spec = (ver, incdir, libdir, lib) else: ver = _GetPythonVersionUNIX(specString) if ver is not None: # not specString but 2 dirs up (as specString is the path to the python executable) d = os.path.dirname(specString) if os.path.basename(d) == "bin": d = os.path.dirname(d) incdir = excons.joinpath(d, "include", "python%s" % ver) libdir = excons.joinpath( d, ("lib64" if excons.Build64() else "lib")) lib = "python%s" % ver spec = (ver, incdir, libdir, lib) if spec is None: specErr += "\n" excons.PrintOnce( "Invalid python specification \"%s\".%sAborting build." % (specErr, specString), tool="python") sys.exit(1) # check setup validity if spec is not None: if plat == "darwin": _, incdir, fwdir, fw = spec if fwdir is None: # directly linking version specific framework if not os.path.isdir(incdir) or not os.path.isfile(fw): spec = None else: if not os.path.isdir(incdir) or not os.path.isdir(fwdir): spec = None else: ver, incdir, libdir, lib = spec if not os.path.isdir(incdir) or not os.path.isdir(libdir): spec = None else: if plat == "win32": if not os.path.isfile( excons.joinpath(libdir, "%s.lib" % lib)): spec = None else: if not os.path.isfile( os.path.join(libdir, "lib%s.so" % lib)): spec = None if spec is None: excons.PrintOnce( "Invalid python specification \"%s\". Aborting build." % specString, tool="python") sys.exit(1) excons.PrintOnce("Resolved python for \"%s\": %s" % (specString, ('<current>' if spec is None else spec)), tool="python") _specCache[specString] = spec return spec
def MakeBundle(target=None, source=None, env=None): binaryPath = str(target[0]) excons.PrintOnce("MakeBundle for \"%s\"" % binaryPath, tool="openfx") outPath = excons.joinpath(os.path.dirname(binaryPath), "openfx") ofxName = os.path.basename(binaryPath) BundleDir = excons.joinpath(outPath, ofxName + ".bundle") ContentsDir = excons.joinpath(BundleDir, "Contents") try: os.makedirs(ContentsDir) except: pass BinaryDir = None if sys.platform == "darwin": plistPath = excons.joinpath(ContentsDir, "Info.plist") plist = """ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>%s</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleVersion</key> <string>1.0</string> </dict> </plist> """ % ofxName f = open(plistPath, "w") f.write(plist) f.close() if env["TARGET_ARCH"] == "x64" and "OFX_NEW_PACKAGE" in env and env[ "OFX_NEW_PACKAGE"]: BinaryDir = excons.joinpath(ContentsDir, "MacOS-x86-64") else: BinaryDir = excons.joinpath(ContentsDir, "MacOS") elif sys.platform in ["win32", "cygwin"]: #if pyplat.architecture()[0] == '64bit': if env["TARGET_ARCH"] == "x64": BinaryDir = excons.joinpath(ContentsDir, "Win64") else: BinaryDir = excons.joinpath(ContentsDir, "Win32") else: #if pyplat.architecture()[0] == '64bit': if env["TARGET_ARCH"] == "x64": BinaryDir = excons.joinpath(ContentsDir, "Linux-x86-64") else: BinaryDir = excons.joinpath(ContentsDir, "Linux-x86") try: os.mkdir(BinaryDir) except: pass shutil.copy(binaryPath, BinaryDir) # Doesn't seem to work env.Clean(target, BundleDir)
def GetConf(env, incdir): h5conf = None cfg = {"threadsafe": False, "zlib": False, "szip": False} quiet = not verbose if incdir: # Note: On Fedora 14, H5pubconf.h has been renamed to H5pubconf-64.h # -> be slightly more flexible when looking up this file lst = filter(lambda x: os.path.basename(x).startswith("H5pubconf"), excons.glob(incdir + "/*.h")) if len(lst) > 0: h5conf = lst[0].replace("\\", "/") else: # Look in current include paths for d in env["CPPPATH"]: lst = filter( lambda x: os.path.basename(x).startswith("H5pubconf"), excons.glob(d + "/*.h")) if len(lst) > 0: h5conf = lst[0].replace("\\", "/") break if h5conf: if h5conf in hdf5_confs: quiet = True cfg = hdf5_confs[h5conf] else: if verbose: excons.PrintOnce("Reading configuration header '%s'..." % h5conf, tool="hdf5") f = open(h5conf, "r") for l in f.readlines(): l = l.strip() if ThreadSafe_exp.match(l): cfg["threadsafe"] = True elif Szip_exp.match(l): cfg["szip"] = True elif Zlib_exp.match(l): cfg["zlib"] = True hdf5_confs[h5conf] = cfg f.close() if not quiet: if cfg["threadsafe"]: excons.PrintOnce("Thread safe", tool="hdf5") if cfg["zlib"]: excons.PrintOnce("Using zlib", tool="hdf5") if cfg["szip"]: excons.PrintOnce("Using szip", tool="hdf5") else: excons.WarnOnce("Could not find configuration header", tool="hdf5") return (False, cfg)
def GetLLVMConfig(components=None): global llvm_cfg if llvm_cfg is None: exesuffix = ("" if sys.platform != "win32" else ".exe") llvm_incdir, llvm_libdir = excons.GetDirs("llvm", silent=False) llvm_config = None if llvm_incdir: path = os.path.dirname(llvm_incdir) + "/bin/llvm-config" + exesuffix if os.path.isfile(path): llvm_config = path if llvm_config is None: if llvm_libdir: path = os.path.dirname(llvm_libdir) + "/bin/llvm-config" + exesuffix if os.path.isfile(path): llvm_config = path if llvm_config is None: for d in os.environ["PATH"].split(os.pathsep): path = d + "/llvm-config" + exesuffix if os.path.isfile(path): llvm_config = path break if llvm_config is None: excons.WarnOnce("Could not find 'llvm-config'", tool="llvm") sys.exit(1) excons.PrintOnce("Use '%s'" % llvm_config, tool="llvm") llvm_cfg = {} procargs = {"shell": True, "stdout": subprocess.PIPE, "stderr": subprocess.STDOUT} if llvm_incdir: llvm_cfg["incdir"] = llvm_incdir if llvm_libdir: llvm_cfg["libdir"] = llvm_libdir cmd = "%s --version" % llvm_config p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: llvm_cfg["version_str"] = out.strip() spl = llvm_cfg["version_str"].split(".") llvm_cfg["version_major"] = int(spl[0]) llvm_cfg["version_minor"] = int(spl[1]) else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") llvm_cfg["verison_str"] = "" llvm_cfg["verison_major"] = 0 llvm_cfg["verison_minor"] = 0 cmd = "%s --cppflags" % llvm_config p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: cppflags = out.strip() llvm_cfg["cppflags"] = " " + " ".join(filter(lambda x: not _IsIncludeFlag(x), _FlagsToList(cppflags))) else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") llvm_cfg["cppflags"] = "" cmd = "%s --cxxflags" % llvm_config p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: cxxflags = _FlagsToList(out.strip()) if sys.platform != "win32": llvm_cfg["rtti"] = (not "-fno-rtti" in cxxflags) llvm_cfg["exceptions"] = (not "-fno-exceptions" in cxxflags) else: llvm_cfg["rtti"] = (not "/GR-" in cxxflags) llvm_cfg["exceptions"] = (not "/EHs-c-" in cxxflags) else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") cmd = "%s --libs" % llvm_config if components: if type(components) in (str, unicode): cmd += " %s" % components elif type(components) in (tuple, list, set): cmd += " %s" % " ".join(components) else: excons.WarnOnce("'components' should either be a string or a list of strings.", tool="llvm") p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: libs = [] for l in out.split("\n"): lst = map(_LibName, (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))) libs.extend(lst) llvm_cfg["libs"] = libs else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") llvm_cfg["libs"] = [] cmd = "%s --system-libs" % llvm_config p = subprocess.Popen(cmd, **procargs) out, _ = p.communicate() if p.returncode == 0: libs = [] for l in out.split("\n"): lst = map(_LibName, (_FlagsToList(l) if sys.platform == "win32" else _CleanList(l.split("-l")))) libs.extend(lst) llvm_cfg["syslibs"] = libs else: excons.WarnOnce("'%s' command failed." % cmd, tool="llvm") llvm_cfg["syslibs"] = [] return llvm_cfg