def enscons_defaults(env): """ To avoid setting these in generate(). """ once_key = "_ENSCONS_DEFAULTS" if once_key in env: return env[once_key] = True try: env["ROOT_IS_PURELIB"] except KeyError: env["ROOT_IS_PURELIB"] = env["WHEEL_TAG"].endswith("none-any") env["EGG_INFO_PREFIX"] = GetOption( "egg_base") # pip wants this in a target dir env["WHEEL_DIR"] = GetOption( "wheel_dir") or "dist" # target directory for wheel env["DIST_BASE"] = GetOption("dist_dir") or "dist" env["PACKAGE_NAME"] = env["PACKAGE_METADATA"]["name"] env["PACKAGE_NAME_SAFE"] = normalize_package(env["PACKAGE_NAME"]) env["PACKAGE_VERSION"] = env["PACKAGE_METADATA"]["version"] # place egg_info in src_root if defined if not env["EGG_INFO_PREFIX"] and env["PACKAGE_METADATA"].get("src_root"): env["EGG_INFO_PREFIX"] = env["PACKAGE_METADATA"]["src_root"] # Development .egg-info has no version number. Needs to have # underscore _ and not hyphen - env["EGG_INFO_PATH"] = env["PACKAGE_NAME_SAFE"] + ".egg-info" if env["EGG_INFO_PREFIX"]: env["EGG_INFO_PATH"] = env.Dir(env["EGG_INFO_PREFIX"]).Dir( env["EGG_INFO_PATH"])
def build(src_dir, build_dir, common_construct_vars, bt_cv_pairs): """ src_dir source directory build_dir build directory common_construct_vars {consttruction var : value} Common construction vars for all build versions. bt_cv_pairs [(build type name, construction vars)] Type of construction vars is the same as common_construct_vars """ build_env = BuildEnv(src_dir=src_dir, build_dir=build_dir, common_construct_vars=common_construct_vars, bt_cv_pairs=bt_cv_pairs) if not GetOption('help'): if GetOption('clean'): print misc.text_box('Clean') else: if build_env.in_compile_stage(): print misc.text_box("Compile") print build_env else: assert build_env.in_link_stage() print misc.text_box("Link") for each in build_env.build_configs(): build = Build(build_env, each) build.build()
def MakeBuildRoot(env): """Build root has build/<libabi>-<debug/release/developer> """ try: b = env['BUILDROOT'] except KeyError: b = 'build' build_mode_to_dir = { 'debug': '-debug', 'release': '-release', 'developer': '-dev' } b += '/' + '%s' % (env['libabi']) if env['debug_mode'] != GetOption('debug_mode'): dbg = GetOption('debug_mode') else: dbg = env['debug_mode'] if dbg == 'libs' or dbg == 'all': b += "%s" % build_mode_to_dir['debug'] else: if env['developer'] > 0: b += "%s%d" % (build_mode_to_dir['developer'], env['developer']) else: b += build_mode_to_dir['release'] env['BUILDROOT'] = b
def generate(env): """Add Builders and construction variables to the Environment.""" if not 'nose' in env['TOOLS'][:-1]: env.Tool('system') env.Tool('python') env.Tool('textfile') AddOption('--test-level', dest = 'test-level', type = 'choice', nargs = 1, action = 'store', help = 'Degree of testing', choices = ['none', 'unit', 'inte', 'func'], default = 'unit') env['TEST_LEVEL'] = GetOption('test-level') AddOption('--with-nose-debug', dest = 'with-nose-debug', type = 'choice', nargs = 1, action = 'store', help = 'Degree of testing', choices = ['none', 'gdb', 'pdb', 'ipdb'], default = 'none') env['WITH_NOSE_DEBUG'] = GetOption('with-nose-debug') def Nosetests(env, sources, with_coverage=True, cover_tests=True, cover_inclusive=True, cover_package=''): noseenv = env.Clone() noseenv['ENV'].update(os.environ) TEST_LEVEL = noseenv['TEST_LEVEL'] SYSTEM = noseenv['SYSTEM'] SP_DIR = noseenv['SP_DIR'] categories = ['none', 'unit', 'inte', 'func'] FLAGS = " -s -v" FLAGS += ' -A "' + SYSTEM + ' and level <= ' +str(categories.index(TEST_LEVEL)) + '"' FLAGS += " --with-coverage --cover-erase" * with_coverage FLAGS += " --cover-tests" * cover_tests * with_coverage FLAGS += " --cover-inclusive" * cover_inclusive * with_coverage FLAGS += "".join(" --cover-package=" + packagename for packagename in cover_package.split(" ") if packagename) * with_coverage WITH_NOSE_DEBUG = noseenv['WITH_NOSE_DEBUG'] sources = [source for source in sources if source.suffix == '.py'] if WITH_NOSE_DEBUG == 'gdb': if len(sources) > 0: targets = noseenv.Textfile(target = 'nosetests.gdb', source = ["run " + os.path.join(SP_DIR, "nose", "core.py") + " " + " ".join(source.abspath for source in sources) + FLAGS]) targets += noseenv.Command(".coverage", targets, "gdb python < $SOURCES") return targets else: if not WITH_NOSE_DEBUG == 'none': FLAGS += ' --' + WITH_NOSE_DEBUG + ' --' + WITH_NOSE_DEBUG + '-failures' if len(sources) > 0: target = noseenv.Command(".coverage", sources, "nosetests $SOURCES" + FLAGS) return target env.AddMethod(Nosetests)
def update(self, fname='options.cache'): if os.path.exists(fname) and not GetOption("silent") and\ not GetOption("help"): print """Note: Restoring previous command-line options from '%s'. Please delete this file when trying to start from scratch.""" % fname vars = Variables(fname, self.opts) vars.AddVariables(*self.variables) vars.Update(self.env) vars.Save(fname, self.env)
def get_option(): try: return GetOption('compile_db') except AttributeError: AddOption('--' + option_name, dest='compile_db', metavar='OPTIONS', help=_HELP) return GetOption('compile_db')
def setup_environment(tools): env = None if sys.platform.find('win') == 0: system_root = os.environ['SystemRoot'] comspec = os.environ['ComSpec'] env = { 'PATH': [os.path.dirname(comspec)], 'SystemRoot': os.environ['SystemRoot'], 'ComSpec': comspec, 'TEMP': os.environ['TEMP'], 'TMP': os.environ['TMP'] } else: raise DGSConsException("Platform {} is not supported".format( os.platform)) compiler = GetOption('compiler') if compiler == 'mingw': mingwbin = ARGUMENTS.get('mingwbin') if not mingwbin or not os.path.isdir(mingwbin): raise DGSConsException( "Unable to determine " "Mingw compiler location. " "Provided 'mingwbin' value: {}".format(mingwbin)) env['PATH'].append(mingwbin) tools.append('mingw') else: raise DGSConsException( "Compiler type {} is not supported".format(compiler)) compile_mode = '' variant = GetOption('variant') if variant == 'Debug': compile_mode = '-g' elif variant == 'Release': compile_mode = '-O2' else: raise DGSConsException("Variant {} is not supported".format(variant)) default_environment = DefaultEnvironment( ENV=env, tools=tools, VARIANT=variant, CCFLAGS=compile_mode, CXXFLAGS=compile_mode, LINKFLAGS=compile_mode, QTDIR=ARGUMENTS.get('qtroot', None), DGDINC=ARGUMENTS.get('dgdinc', None)) if GetOption('dumpenv'): print default_environment.Dump() default_environment.Exit(0) return default_environment
def generate(env, **kw): global added if not added: added = 1 AddOption( '--enable-Trace', dest='Trace', action='store_true', help='Enable trace support by defining COAST_TRACE, (StartTrace,\ Trace,...), see Tracer.h for details') import socket envconfigdir_default = socket.gethostname() AddOption( '--env-cfg', dest='envconfigdir', action='store', nargs=1, type='string', default=envconfigdir_default, help='Define directory name to use for location dependent files,\ default [' + envconfigdir_default + ']. When a config file gets copied and\ a corresponding file exists below this directory, it will get used instead\ of the original one. This allows to define configuration settings appropriate\ for the current environment.') buildflags = [] buildmode = GetOption('buildcfg') if buildmode == 'optimized': buildflags.append('OPT') elif buildmode == 'debug': buildflags.append('DBG') else: buildflags.append('PROFILE') if GetOption('Trace'): env.AppendUnique(VARIANT_SUFFIX=['_trace']) env.AppendUnique(CPPDEFINES=['COAST_TRACE']) buildflags.append('TRACE') env.AppendUnique(CPPDEFINES=[ 'COAST_BUILDFLAGS' + '="\\"' + '_'.join(buildflags) + '\\""' ]) compilerstring = [env.get('CXX', 'unknown')] if env.get('CXXVERSION', ''): compilerstring.append(env.get('CXXVERSION', 'unknown')) if env.get('CXXFLAVOUR', ''): compilerstring.append(env.get('CXXFLAVOUR', 'unknown')) env.AppendUnique(CPPDEFINES=[ 'COAST_COMPILER' + '="\\"' + '_'.join(compilerstring) + '\\""' ]) env['__envconfigdir__'] = Dir(GetOption('envconfigdir')) logger.info("environment specific directory: %s", env['__envconfigdir__'].get_abspath())
def generate(env): from SCons.Script import AddOption, GetOption global added if not added: added = 1 AddOption( '--install-sandbox', dest='install_sandbox', type="string", action="store", help='A directory under which all installed files will be placed.') global BaseInstallBuilder if BaseInstallBuilder is None: install_sandbox = GetOption('install_sandbox') if install_sandbox: target_factory = DESTDIR_factory(env, install_sandbox) else: target_factory = env.fs BaseInstallBuilder = SCons.Builder.Builder( action=install_action, target_factory=target_factory.Entry, source_factory=env.fs.Entry, multi=1, emitter=[ add_targets_to_INSTALLED_FILES, ], name='InstallBuilder') try: env['BUILDERS']['Install'] except KeyError, e: env['BUILDERS']['Install'] = InstallBuilderWrapper
def sprint(message, *args): """Silent-mode-aware SCons message printer.""" if not GetOption('silent'): if args: print 'scons:', message % (args) else: print 'scons:', message
def update(self, fname): if os.path.exists(fname) and not GetOption("silent") and not env.GetOption("help"): print "Restoring previous command-line options from '%s'" % fname vars = Variables(fname, self.opts) vars.AddVariables(*self.variables) vars.Update(env) vars.Save(fname, env)
def is64bit(self): if hasattr(self, "_bit64"): return self._bit64 ARCH = GetOption("arch") if ARCH == "x64": self._bit64 = True elif ARCH == "x86": self._bit64 = False else: if ARCH not in [None, "detect"]: import warnings warnings.warn("Unknown arch value. Using 'detect'") if self.iswin32(): # Work around for 32bit Windows executables try: import win32process self._bit64 = win32process.IsWow64Process() except: import ctypes, sys i = ctypes.c_int() kernel32 = ctypes.windll.kernel32 process = kernel32.GetCurrentProcess() kernel32.IsWow64Process(process, ctypes.byref(i)) self._bit64 = (i.value != 0) else: import platform self._bit64 = platform.architecture()[0] == "64bit" if not self.omero_quiet: print "64-Bit build: %s (%s)" % (self._bit64, ARCH) return self._bit64
def add_option(self, *args, **kw): AddOption(*args, **kw) key = kw.get('dest') value = GetOption(key) defvalue = kw.get('default') self.variables.append((key, '', defvalue)) if value != defvalue: self.opts[key] = value
def generate(env): # Validate the --flavor option flavor = GetOption('flavor') if not (flavor in ['debug', 'release']): print("*** build-flavor: Invalid value for option '--flavor': '" + flavor + "'. Valid values are: ('debug', 'release')") Exit(1) if not GetOption('silent'): if GetOption('clean'): print('build.flavor: Cleaning ' + flavor + ' flavor...') else: print('build.flavor: Building ' + flavor + ' flavor...') # MSVC: Enable exception unwind semantics env.AppendUnique(CCFLAGS=['/EHsc']) # MSVC: Compile for multi-threaded [debug] CRT env.AppendUnique(CCFLAGS=['/MDd'] if flavor == 'debug' else ['/MD']) # Define _DEBUG or NDEBUG based on build flavor env.AppendUnique( CCFLAGS=['/D_DEBUG'] if flavor == 'debug' else ['/DNDEBUG']) # MSVC: Geerate a PDB env.AppendUnique(CCFLAGS=['/Zi']) env.AppendUnique(LINKFLAGS=['/DEBUG:FULL']) # MSVC: Enable optimizations in release mode if flavor == 'release': env.AppendUnique(CCFLAGS=['/Ox', '/GL']) env.AppendUnique(LINKFLAGS=['/LTCG', '/OPT:REF', '/OPT:ICF']) env.AppendUnique(ARFLAGS=['/LTCG']) # MSVC: Compiler warning level env.AppendUnique(CCFLAGS=['/W1']) # MSVC: Enable extra debugging checks in debug mode #if flavor == 'debug': # env.AppendUnique(CCFLAGS = ['/sdl']) # Tell VCPkg to use debug libraries for a debug build, unless specifically overridden env.SetDefault(VCPKGDEBUG=(flavor == 'debug'))
def CheckBuildConfiguration(conf): # gcc 4.7.0 generates buggy code when optimization is turned on. opt_level = GetOption('opt') if ((opt_level == 'production' or opt_level == 'profile') and \ (conf.env['CC'].endswith("gcc") or conf.env['CC'].endswith("g++"))): if commands.getoutput(conf.env['CC'] + ' -dumpversion') == "4.7.0": print "Unsupported/Buggy compiler gcc 4.7.0 for building " + \ "optimized binaries" raise convert_to_BuildError(1) return conf.Finish()
def generate(env): from SCons.Script import AddOption, GetOption global added if not added: added = 1 AddOption( '--install-sandbox', dest='install_sandbox', type="string", action="store", help='A directory under which all installed files will be placed.') global BaseInstallBuilder if BaseInstallBuilder is None: install_sandbox = GetOption('install_sandbox') if install_sandbox: target_factory = DESTDIR_factory(env, install_sandbox) else: target_factory = env.fs BaseInstallBuilder = SCons.Builder.Builder( action=install_action, target_factory=target_factory.Entry, source_factory=env.fs.Entry, multi=1, emitter=[ add_targets_to_INSTALLED_FILES, ], name='InstallBuilder') env['BUILDERS']['_InternalInstall'] = InstallBuilderWrapper env['BUILDERS']['_InternalInstallAs'] = InstallAsBuilderWrapper # We'd like to initialize this doing something like the following, # but there isn't yet support for a ${SOURCE.type} expansion that # will print "file" or "directory" depending on what's being # installed. For now we punt by not initializing it, and letting # the stringFunc() that we put in the action fall back to the # hand-crafted default string if it's not set. # #try: # env['INSTALLSTR'] #except KeyError: # env['INSTALLSTR'] = 'Install ${SOURCE.type}: "$SOURCES" as "$TARGETS"' try: env['INSTALL'] except KeyError: env['INSTALL'] = copyFunc
def Package(env, target=None, source=None, **kw): """ Entry point for the package tool. """ # check if we need to find the source files ourself if not source: source = env.FindInstalledFiles() if len(source) == 0: raise UserError, "No source for Package() given" # decide which types of packages shall be built. Can be defined through # four mechanisms: command line argument, keyword argument, # environment argument and default selection( zip or tar.gz ) in that # order. try: kw['PACKAGETYPE'] = env['PACKAGETYPE'] except KeyError: pass if not kw.get('PACKAGETYPE'): from SCons.Script import GetOption kw['PACKAGETYPE'] = GetOption('package_type') if kw['PACKAGETYPE'] == None: if env['BUILDERS'].has_key('Tar'): kw['PACKAGETYPE'] = 'targz' elif env['BUILDERS'].has_key('Zip'): kw['PACKAGETYPE'] = 'zip' else: raise UserError, "No type for Package() given" PACKAGETYPE = kw['PACKAGETYPE'] if type(PACKAGETYPE) is ModuleType: PACKAGETYPE = [PACKAGETYPE] elif not is_List(PACKAGETYPE): PACKAGETYPE = string.split(PACKAGETYPE, ',') # load the needed packagers. def load_packager(typ): if type(typ) is ModuleType: # Caller wants to use a custom packager return typ try: file, path, desc = imp.find_module(typ, __path__) return imp.load_module(typ, file, path, desc) except ImportError, e: raise EnvironmentError("packager %s not available: %s" % (typ, str(e)))
def generate(env): """Add Builders and construction variables for Xcode project files to an Environment.""" from SCons.Script import AddOption, GetOption, SetOption global _added if not _added: _added = True AddOption( "--xcode-action", dest="xcode_action", type="string", action="store", default="", help="The action Xcode wishes to perform", ) AddOption( "--xcode-variant", dest="xcode_variant", type="string", action="store", default="", help="The variant Xcode wishes to activate", ) xcode = GetOption("xcode_action") if xcode == "clean": SetOption("clean", True) projectAction = SCons.Action.Action(GenerateProject, None) projectBuilder = SCons.Builder.Builder( action="$XCODEPROJECTCOM", suffix="$XCODEPROJECTSUFFIX", emitter=projectEmitter, target_factory=env.fs.Dir, source_factory=env.fs.Dir, ) if "XcodeProject" not in env: env["BUILDERS"]["XcodeProject"] = projectBuilder env["XCODEPROJECTCOM"] = projectAction env["XCODEPROJECTSUFFIX"] = ".xcodeproj" env["XCODEORGANIZATION"] = "n/a" if "XCODE" not in env: env["XCODE"] = {}
def isdebug(self): if hasattr(self, "_isdbg"): return self._isdbg RELEASE = GetOption("release") if RELEASE == "Os": self._isdbg = False else: self._isdbg = True if RELEASE not in [None, "debug"]: import warnings warnings.warn("Unknown release value. Using 'debug'") print "Debug setting: %s (%s)" % (self._isdbg, RELEASE) return self._isdbg
def generate(env, **kwargs): if not 'prefix' in env['TOOLS'][:-1]: env.Tool('system') SYSTEM = env['SYSTEM'] sysprefix = sys.prefix if SYSTEM == 'win': sysprefix = os.path.join(sysprefix, 'Library') AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix', default=sysprefix) env['PREFIX'] = GetOption('prefix')
def add_rpaths(env, install_off, set_cgo_ld, is_bin): """Add relative rpath entries""" if GetOption('no_rpath'): if set_cgo_ld: env.AppendENVPath("CGO_LDFLAGS", env.subst("$_LIBDIRFLAGS "), sep=" ") return env.AppendUnique(RPATH_FULL=['$PREFIX/lib64']) rpaths = env.subst("$RPATH_FULL").split() prefix = env.get("PREFIX") if not is_bin: path = r'\$$ORIGIN' env.AppendUnique(RPATH=[DaosLiteral(path)]) for rpath in rpaths: if rpath.startswith('/usr'): env.AppendUnique(RPATH=[rpath]) continue if install_off is None: env.AppendUnique(RPATH=[os.path.join(prefix, rpath)]) continue relpath = os.path.relpath(rpath, prefix) if relpath != rpath: joined = os.path.normpath(os.path.join(install_off, relpath)) path = r'\$$ORIGIN/%s' % (joined) if set_cgo_ld: env.AppendENVPath("CGO_LDFLAGS", "-Wl,-rpath=$ORIGIN/%s/%s" % (install_off, relpath), sep=" ") else: env.AppendUnique(RPATH=[DaosLiteral(path)]) for rpath in rpaths: path = os.path.join(prefix, rpath) if is_bin: # NB: Also use full path so intermediate linking works env.AppendUnique(LINKFLAGS=["-Wl,-rpath-link=%s" % path]) else: # NB: Also use full path so intermediate linking works env.AppendUnique(RPATH=[path]) if set_cgo_ld: env.AppendENVPath("CGO_LDFLAGS", env.subst("$_LIBDIRFLAGS " "$_RPATH"), sep=" ")
def generate(env, **kwargs): if not 'system' in env['TOOLS'][:-1]: SYSTEMS = dict(Linux="linux", Darwin="osx", Windows="win") system = str(platform.system()) if not system in SYSTEMS: raise ValueError('`' + system + '` is not a valid operating system') else: system = SYSTEMS[system] AddOption('--system', dest='system', type='choice', nargs=1, action='store', help='system', choices=list(SYSTEMS.values()), default=system) env['SYSTEM'] = GetOption('system')
def Enable(env): _set_variant(env, {True: 'release', False: 'debug'}[GetOption('release')]) _set_default_build_configuration(env) _set_output_colors(env) env['X_BUILD_MANIFEST'] = {} env.AddMethod(_get_project_dir, 'GetProjectRoot') env.AddMethod(_get_variant, 'GetVariant') env.AddMethod(_install_files, 'InstallFiles') env.AddMethod(_export_bin, 'ExportBin') env.AddMethod(_export_lib, 'ExportLib') env.AddMethod(_export_include, 'ExportInclude') env.AddMethod(_manifest_build_settings, 'ManifestBuildSettings') env.AddMethod(_build_units, 'QuickBuild') env.AddMethod(_quick_program, 'QuickProgram') env.AddMethod(_quick_static_lib, 'QuickStaticLib') env.AddMethod(_quick_shared_lib, 'QuickSharedLib')
def _configure_mpi_pkg(env, libs): """Configure MPI using pkg-config""" if GetOption('help'): return "mpi" if _find_mpicc(env): return env.subst("$MPI_PKG") try: env.ParseConfig("pkg-config --cflags --libs $MPI_PKG") except OSError as e: print("\n**********************************") print("Could not find package MPI_PKG=%s\n" % env.subst("$MPI_PKG")) print("Unset it or update PKG_CONFIG_PATH") print("**********************************") raise e # assume mpi is needed in the fallback case libs.append('mpi') return env.subst("$MPI_PKG")
def parms(target, source, env): """Assemble various Make parameters.""" if 'MakePath' not in env: print("Make builder requires MakePath variable") sys.exit(1) make_path = env.subst(str(env['MakePath'])) make_cmd = 'make' if 'MakeCmd' in env: make_cmd = env.subst(env['MakeCmd']) elif 'MAKE' in env: make_cmd = env.subst(env['MAKE']) make_env = None if env.get('CROSS_BUILD'): make_env = env['CROSS_ENV'] if 'MakeEnv' in env: if make_env == None: make_env = {} else: # We're appending to an existing dictionary, so create a copy # instead of appending to the original env['CROSS_ENV'] make_env = env['CROSS_ENV'][:] for (k, v) in env['MakeEnv'].items(): make_env[k] = v make_opts = None if 'MakeOpts' in env: make_opts = env.subst(env['MakeOpts']) make_jobs = GetOption('num_jobs') if 'MakeOneThread' in env and env['MakeOneThread']: make_jobs = 1 make_targets = None if 'MakeTargets' in env: make_targets = env.subst(env['MakeTargets']) out = env.get('MakeStdOut') return (make_path, make_env, make_targets, make_cmd, make_jobs, make_opts, out)
def exists(env): """Enable if called.""" if 'ninja' not in GetOption('experimental'): return False # This variable disables the tool when storing the SCons command in the # generated ninja file to ensure that the ninja tool is not loaded when # SCons should do actual work as a subprocess of a ninja build. The ninja # tool is very invasive into the internals of SCons and so should never be # enabled when SCons needs to build a target. if env.get("__NINJA_NO", "0") == "1": return False # pypi ninja module detection done at top of file during import ninja. if NINJA_BINARY: return NINJA_BINARY else: raise SCons.Warnings.SConsWarning("Failed to import ninja, attempt normal SCons build.")
def generate(env): """Add Builders and construction variables for Xcode project files to an Environment.""" from SCons.Script import AddOption, GetOption, SetOption global _added if not _added: _added = True AddOption('--xcode-action', dest='xcode_action', type='string', action='store', default='', help='The action Xcode wishes to perform') AddOption('--xcode-variant', dest='xcode_variant', type='string', action='store', default='', help='The variant Xcode wishes to activate') xcode = GetOption('xcode_action') if xcode == 'clean': SetOption('clean', True) projectAction = SCons.Action.Action(GenerateProject, None) projectBuilder = SCons.Builder.Builder(action='$XCODEPROJECTCOM', suffix='$XCODEPROJECTSUFFIX', emitter=projectEmitter, target_factory=env.fs.Dir, source_factory=env.fs.Dir) if 'XcodeProject' not in env: env['BUILDERS']['XcodeProject'] = projectBuilder env['XCODEPROJECTCOM'] = projectAction env['XCODEPROJECTSUFFIX'] = '.xcodeproj' env['XCODEORGANIZATION'] = 'n/a' if 'XCODE' not in env: env['XCODE'] = {}
def configure_mpi(env): """Check if mpi exists and configure environment""" if GetOption('help'): return True env['CXX'] = None if env.subst("$MPI_PKG") != "": return _configure_mpi_pkg(env) for mpi in ['openmpi', 'mpich']: if not load_mpi(mpi): continue if _find_mpicc(env): print("%s is installed" % mpi) return True print("No %s installed and/or loaded" % mpi) print("No MPI installed") return False
def exists(env): """Enable if called.""" if 'ninja' not in GetOption('experimental'): return False # This variable disables the tool when storing the SCons command in the # generated ninja file to ensure that the ninja tool is not loaded when # SCons should do actual work as a subprocess of a ninja build. The ninja # tool is very invasive into the internals of SCons and so should never be # enabled when SCons needs to build a target. if env.get("__NINJA_NO", "0") == "1": return False try: import ninja return ninja.__file__ except ImportError: SCons.Warnings.SConsWarning( "Failed to import ninja, attempt normal SCons build.") return False
def generate(env): """Add Builders and construction variables to the Environment.""" if not 'toolchain' in env['TOOLS'][:-1]: AddOption('--arch', dest='arch', type='choice', nargs=1, action='store', help='Target architecture', choices=['32', '64'], default='64' if maxsize.bit_length() == 63 else '32') env.Tool('system') SYSTEM = env['SYSTEM'] env['ARCH'] = GetOption('arch') ARCH = env['ARCH'] AddOption('--debug-symbols', dest='debug-symbols', type='choice', nargs=1, action='store', help='Debug symbols', default='no', choices=['no', 'yes']) env['DEBUG_SYMBOLS'] = GetOption('debug-symbols') DEBUG_SYMBOLS = env['DEBUG_SYMBOLS'] if DEBUG_SYMBOLS == 'yes': if SYSTEM == 'win': env.AppendUnique(CCFLAGS=['/DEBUG:FULL']) else: env.AppendUnique(CCFLAGS=['-g']) if SYSTEM == 'win': env['TARGET_ARCH'] = 'amd64' if ARCH == '64' else 'x86' env['HOST_ARCH'] = env['TARGET_ARCH'] AddOption('--msvc-version', dest='msvc-version', type='string', nargs=1, action='store', help='MSVC version', default='12.0') #'14.0') env['MSVC_VERSION'] = GetOption('msvc-version') else: AddOption('--visibility', dest='visibility', type='choice', nargs=1, action='store', help='Symbol visibility', choices=['hidden', 'default'], default='hidden') env['VISIBILITY'] = GetOption('visibility') if SYSTEM == 'linux': AddOption('--diagnostics-color', dest='diagnostics-color', type='choice', nargs=1, action='store', help='Diagnostics color', default='always', choices=['always', 'never']) env['DIAGNOSTICS_COLOR'] = GetOption('diagnostics-color') env.Tool('default') env.Tool('prefix') if SYSTEM == 'win': env.AppendUnique(CCFLAGS=[ '/O2', '/Ob2', '/MD', '/GR', '/EHsc', '/Gy', '/GF', '/GA' ], CPPDEFINES=['WIN32', 'UNICODE']) env.PrependUnique(CPPPATH=['$PREFIX\include']) env.PrependUnique(LIBPATH=['$PREFIX\lib', '$PREFIX\..\libs']) else: VISIBILITY = env['VISIBILITY'] env.PrependUnique(CPPPATH=['$PREFIX/include'], LIBPATH=['$PREFIX/lib'], CFLAGS=["-std=c11"], CCFLAGS=['-fvisibility=' + VISIBILITY], CXXFLAGS=["-std=c++11"]) # env['SHLINK'] = os.environ['LD'] env['AR'] = os.environ['AR'] env['AS'] = os.environ['AS'] if ARCH == '32': env.AppendUnique(CCFLAGS=['-m32']) if SYSTEM == 'osx': env['CC'] = os.environ['CLANG'] env['CXX'] = os.environ.get('CLANGXX', os.environ.get('CLANG__')) env.AppendUnique(CXXFLAGS=['-stdlib=libc++']) else: env['CC'] = os.environ['GCC'] env['CXX'] = os.environ['GXX'] DIAGNOSTICS_COLOR = env['DIAGNOSTICS_COLOR'] env.AppendUnique(CCFLAGS=['-Wl,--no-undefined'] + ['-fdiagnostics-color=' + DIAGNOSTICS_COLOR])