예제 #1
0
    def __init__(self, **kwargs):
        try:
            tools = list(kwargs.pop("tools"))
            tools.append('packaging')
        except KeyError:
            tools = ['default', 'packaging']

        # omero_quiet is for internal use in order to
        # quiet down this instance for re-use.
        try:
            self.omero_quiet = kwargs.pop("omero_quiet")
        except KeyError:
            self.omero_quiet = False

        try:
            AddOption('--release',
                      dest='release',
                      type='string',
                      nargs=1,
                      action='store',
                      metavar='RELEASE',
                      help='Release version [debug (default) or Os]')

            AddOption(
                '--arch',
                dest='arch',
                type='string',
                nargs=1,
                action='store',
                metavar='ARCH',
                help='Architecture to build for [x86, x64, or detect (default)]'
            )
        except optparse.OptionConflictError, e:
            pass  # These are global so this has been used twice
예제 #2
0
    def add_options(cls):
        AddOption('--boost-version',
                  dest='boost-version',
                  type='string',
                  nargs=1,
                  action='store',
                  help='Boost Version to build against')

        AddOption('--boost-home',
                  dest='boost-home',
                  type='string',
                  nargs=1,
                  action='store',
                  help='The location of the boost source code')

        AddOption(
            '--boost-build-once',
            dest='boost-build-once',
            action='store_true',
            help=
            "Pass this if you know the source won't change and you only need the libraries built the first time"
        )

        AddOption(
            '--boost-verbose',
            dest='boost-verbose',
            action='store_true',
            help=
            "Pass this option if you wish to see the command-line output of boost build"
        )
예제 #3
0
    def add_options(cls):
        def parse_paths_option(option, opt, value, parser):
            parser.values.excluded_paths_starting = value.split(',')

        AddOption('--generate-cbs',
                  dest='generate-cbs',
                  action='store_true',
                  help='Tell scons to generate a Codeblocks project',
                  default=False)

        AddOption(
            '--generate-cbs-ignore-variant',
            dest='generate-cbs-ignore-variant',
            action='store_true',
            help=
            'Ignore build variants when creating the file list for the project',
            default=False)

        AddOption(
            '--generate-cbs-exclude-paths-starting',
            type='string',
            nargs=1,
            action='callback',
            callback=parse_paths_option,
            help=
            'Exclude dependencies starting with the specified paths from the file list for the project'
        )
예제 #4
0
파일: nose.py 프로젝트: pythseq/StatisKit
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 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())
예제 #6
0
def generate(env):
    env.AddMethod(BoostLibrary)
    env.AddMethod(BoostUseLib)
    env.AddMethod(PythonExtension)

    env.Replace(
        INSTALL = boost_copy_func,
        BOOST_CURRENT_VARIANT_DIR = "#/$BOOST_BUILD_DIR/$current_variant/$linking/threading-$current_threading"
    )

    AddOption('--stage', dest='stage', action="store_true")
    AddOption('--install', dest='install', action="store_true")
예제 #7
0
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"] = {}
예제 #8
0
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
예제 #9
0
 def add_options(cls):
     AddOption('--asio-home',
               dest='asio-home',
               type='string',
               nargs=1,
               action='store',
               help='asio version to build against')
예제 #10
0
def generate(env):
    """
    Set up enscons in Environment env
    """

    # pure-Python tar
    from . import pytar

    pytar.generate(env)

    if not hasattr(generate, "once"):
        AddOption(
            "--egg-base",
            dest="egg_base",
            type="string",
            nargs=1,
            action="store",
            metavar="DIR",
            help="egg-info target directory",
        )

        AddOption(
            "--wheel-dir",
            dest="wheel_dir",
            type="string",
            nargs=1,
            action="store",
            metavar="DIR",
            help="wheel target directory",
        )

        AddOption(
            "--dist-dir",
            dest="dist_dir",
            type="string",
            nargs=1,
            action="store",
            metavar="DIR",
            help="sdist target directory",
        )

        generate.once = True

    env.AddMethod(Whl)
    env.AddMethod(WhlFile)
    env.AddMethod(SDist)
예제 #11
0
def ninja_add_command_line_options():
    """
    Add additional command line arguments to SCons specific to the ninja tool
    """
    AddOption('--disable-execute-ninja',
              dest='disable_execute_ninja',
              metavar='BOOL',
              action="store_true",
              default=False,
              help='Disable ninja automatically building after scons')

    AddOption('--disable-ninja',
              dest='disable_ninja',
              metavar='BOOL',
              action="store_true",
              default=False,
              help='Disable ninja automatically building after scons')
예제 #12
0
 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
예제 #13
0
 def get_option():
     try:
         return GetOption('compile_db')
     except AttributeError:
         AddOption('--' + option_name,
                   dest='compile_db',
                   metavar='OPTIONS',
                   help=_HELP)
         return GetOption('compile_db')
예제 #14
0
def generate(env):
    AddOption('--test', dest='test', action="store_true")

    env.AddMethod(BoostCompileTest)
    env.AddMethod(BoostRun)
    env.AddMethod(BoostRunPythonScript)
    env.AddMethod(BoostRunTest)
    env.AddMethod(BoostRunTests)
    env.AddMethod(BoostCompileTests)
    env.AddMethod(BoostTestSummary)
예제 #15
0
def init(env):
    AddOption('--type',
              dest='type',
              type='string',
              nargs=1,
              action='store',
              help='type of build, options: release, opt')
    (arch, binType) = platform.architecture()
    if binType == 'ELF':
        LinuxOptions(env)
예제 #16
0
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'] = {}
예제 #17
0
def ninja_add_command_line_options():
    """
    Add additional command line arguments to SCons specific to the ninja tool
    """
    AddOption('--disable-execute-ninja',
              dest='disable_execute_ninja',
              metavar='BOOL',
              action="store_true",
              default=False,
              help='Disable automatically running ninja after scons')

    AddOption(
        '--disable-ninja',
        dest='disable_ninja',
        metavar='BOOL',
        action="store_true",
        default=False,
        help=
        'Disable ninja generation and build with scons even if tool is loaded. '
        + 'Also used by ninja to build targets which only scons can build.')
예제 #18
0
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
예제 #19
0
    def Add(self, *args, **kwargs):
        col_width = 30

        help = "  " + ", ".join(args)
        if "help" in kwargs:
            length = len(help)
            if length >= col_width:
                help += "\n" + " " * col_width
            else:
                help += " " * (col_width - length)
            help += kwargs["help"]
        self.__help_texts += help + "\n"

        AddOption(*args, **kwargs)
예제 #20
0
def generate(env):
    global added
    if not added:
        added = True
        AddOption('--package-type',
                  dest='package_type',
                  default=None,
                  type="string",
                  action="store",
                  help='The type of package to create.')

    try:
        env['BUILDERS']['Package']
        env['BUILDERS']['Tag']
    except KeyError:
        env['BUILDERS']['Package'] = Package
        env['BUILDERS']['Tag'] = Tag
예제 #21
0
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')
예제 #22
0
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')
예제 #23
0
파일: Cog.py 프로젝트: neojiangtw/numcpp-1
def generate(env):

    env['COG'] = exists(env)

    python = File(sys.executable).get_abspath()

    # windows fixes
    python = python.replace("\\", "\\\\")

    env['PYTHON'] = python

    # default cog flags

    env['COGFLAGS'] = ''.join([
        '-d ',  # deletes the generator code from the output
        '-e ',  # warns if the input file has no cog code in it.
        '-I submods/xgen_ws ',  # includes in python path
        '-I "%s" ' %
        TOOLS_DIR,  # include the tools dir so cog_warnign can be imported
        '-D __COGFILE__="$SOURCE" ',  # defines a global string for cog program
    ])

    cmd = '$PYTHON -m cogapp -o $TARGET $COGFLAGS $SOURCE'

    env['COGCOM'] = cmd

    action = Action('$COGCOM', '$COGCOMSTR')

    bld = env.Builder(
        action=[action],
        emitter=emitter,
    )

    env['BUILDERS']['Cog'] = bld
    env['BUILDERS']['rebuild_cog'] = rebuild_cog

    if not VERBOSE:
        env['COGCOMSTR'] = 'Processing $SOURCE --> $TARGET'

    AddOption("--cog",
              dest="cog",
              action="store_true",
              default=False,
              help="Forces .cog files to be rebuilt")
예제 #24
0
def init(env):
    AddOption('--verbose',
              dest='verbose',
              action='store_true',
              help='Display a more detailed output.',
              default=False)
    AddOption(
        '--buildtests',
        dest='buildtests',
        action='store_true',
        help=
        '''this flag is used to test the build environment, it will parse the buildtests folder instead of the projects folder''',
        default=False)
    AddOption(
        '--forcerun',
        dest='forcerun',
        action='store_true',
        help=
        '''if indicated, tests will run regardless something they depend on changed, if not indicated, tests will only run if something that they depend on changed''',
        default=False)
    AddOption(
        '--nostdin',
        dest='nostdin',
        action='store_true',
        help=
        '''this flag is used to avoid the environment to use stdin to ask stuff, it should assume the default behavior (added to support Eclipse plugin)''',
        default=False)
    AddOption(
        '--testsuite',
        dest='testsuite',
        action='store',
        type='string',
        default="*",
        help=
        'Specifies the test suite that will be run. Default is all tests suit.'
    )
    AddOption('--namecheck',
              dest='namecheck',
              action='store_true',
              help='Check names conventions.',
              default=False)
    AddOption('--exclude-headers',
              dest='exclude_headers',
              action='store_true',
              help='Exclude header files in :static-analysis check.',
              default=False)
예제 #25
0
def LinuxOptions(env):
    AddOption('--effective',
              dest='effective',
              action='store_true',
              help='Sets the effective C++ mode',
              default=False)
    # Common options.
    commonFlags = ['-Wall', '-Wextra', '-pedantic', '-ansi']
    env.Append(CXXFLAGS=commonFlags, CFLAGS=commonFlags)
    # Options for 64bit archs
    (arch, binType) = platform.architecture()
    if arch == '64bit':
        env.Append(CXXFLAGS='-fPIC', CFLAGS='-fPIC')
    # Build type options
    if env.GetOption('type') == 'opt':
        optFlags = ['-O3']
        env.Append(CXXFLAGS=optFlags, CFLAGS=optFlags)
        env.Append(CPPDEFINES=['NDEBUG'])
    elif env.GetOption('type') != 'release':
        dbgFlags = ['-ggdb3']
        env.Append(CXXFLAGS=dbgFlags, CFLAGS=dbgFlags)
        env.Append(CPPDEFINES=['DEBUG'])
예제 #26
0
def AddOptions():
    ''' ===== Add generic options to SCons ===== '''

    AddOption('--dist',
                      dest = 'make-dist',
                      action = 'store_true',
                      default = False,
                      help = 'make distribution')
    AddOption('--dist-strip',
                      dest = 'make-dist-strip',
                      action = 'store_true',
                      default = False,
                      help = 'make distribution and strip useless files')
    AddOption('--dist-ide',
                      dest = 'make-dist-ide',
                      action = 'store_true',
                      default = False,
                      help = 'make distribution for RT-Thread Studio IDE')
    AddOption('--project-path',
                      dest = 'project-path',
                      type = 'string',
                      default = None,
                      help = 'set dist-ide project output path')
    AddOption('--project-name',
                      dest = 'project-name',
                      type = 'string',
                      default = None,
                      help = 'set project name')
    AddOption('--reset-project-config',
                      dest = 'reset-project-config',
                      action = 'store_true',
                      default = False,
                      help = 'reset the project configurations to default')
    AddOption('--cscope',
                      dest = 'cscope',
                      action = 'store_true',
                      default = False,
                      help = 'Build Cscope cross reference database. Requires cscope installed.')
    AddOption('--clang-analyzer',
                      dest = 'clang-analyzer',
                      action = 'store_true',
                      default = False,
                      help = 'Perform static analyze with Clang-analyzer. ' + \
                           'Requires Clang installed.\n' + \
                           'It is recommended to use with scan-build like this:\n' + \
                           '`scan-build scons --clang-analyzer`\n' + \
                           'If things goes well, scan-build will instruct you to invoke scan-view.')
    AddOption('--buildlib',
                      dest = 'buildlib',
                      type = 'string',
                      help = 'building library of a component')
    AddOption('--cleanlib',
                      dest = 'cleanlib',
                      action = 'store_true',
                      default = False,
                      help = 'clean up the library by --buildlib')
    AddOption('--target',
                      dest = 'target',
                      type = 'string',
                      help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
    AddOption('--stackanalysis',
                dest = 'stackanalysis',
                action = 'store_true',
                default = False,
                help = 'thread stack static analysis')
    AddOption('--genconfig',
                dest = 'genconfig',
                action = 'store_true',
                default = False,
                help = 'Generate .config from rtconfig.h')
    AddOption('--useconfig',
                dest = 'useconfig',
                type = 'string',
                help = 'make rtconfig.h from config file.')
    AddOption('--verbose',
                dest = 'verbose',
                action = 'store_true',
                default = False,
                help = 'print verbose information during build')
    AddOption('--pyconfig',
                dest = 'pyconfig',
                action = 'store_true',
                default = False,
                help = 'Python GUI menuconfig for RT-Thread BSP')
    AddOption('--pyconfig-silent',
                dest = 'pyconfig_silent',
                action = 'store_true',
                default = False,
                help = 'Don`t show pyconfig window')
    if platform.system() != 'Windows':
        AddOption('--menuconfig',
                    dest = 'menuconfig',
                    action = 'store_true',
                    default = False,
                    help = 'make menuconfig for RT-Thread BSP')
예제 #27
0
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])
예제 #28
0
    def generate(env):
        """Add Builders and construction variables to the Environment."""

        if not 'autowig' in env['TOOLS'][:-1]:

            env.Tool('textfile')
            env.Tool('system')
            env.Tool('prefix')

            AddOption('--site-autowig',
                      dest='site-autowig',
                      type='string',
                      nargs=1,
                      action='store',
                      metavar='DIR',
                      help='',
                      default=os.path.join(get_python_lib(), 'scons_tools',
                                           'site_autowig'))
            env['SITE_AUTOWIG'] = GetOption('site-autowig')

            AddOption('--autowig-no-wrappers',
                      dest='autowig_no_wrappers',
                      action='store_true',
                      default=False,
                      help="Do not write wrappers")
            env['AUTOWIG_NO_WRAPPERS'] = GetOption('autowig_no_wrappers')

            def boost_python_builder(target, source, env):
                SITE_AUTOWIG = env['SITE_AUTOWIG']
                if 'AUTOWIG_ASG' in env:
                    try:
                        env['AUTOWIG_ASG'][
                            env['AUTOWIG_generator_module'].abspath].remove()
                    except:
                        pass
                env['AUTOWIG_ASG'] = autowig.AbstractSemanticGraph()
                asg = env['AUTOWIG_ASG']
                for dependency in env['AUTOWIG_DEPENDS']:
                    with open(
                            os.path.join(SITE_AUTOWIG, 'ASG',
                                         dependency + '.pkl'),
                            'rb') as filehandler:
                        asg.merge(pickle.load(filehandler))
                AUTOWIG_PARSER = env['AUTOWIG_PARSER']
                if not AUTOWIG_PARSER in autowig.parser:
                    filename = os.path.join(SITE_AUTOWIG, 'parser',
                                            AUTOWIG_PARSER + '.py')
                    exec(
                        compile(open(filename, "rb").read(), filename, 'exec'),
                        globals(), locals())
                    autowig.parser[AUTOWIG_PARSER] = locals()['parser']
                autowig.parser.plugin = AUTOWIG_PARSER
                kwargs = {
                    kwarg[len('AUTOWIG_parser_'):]: env[kwarg]
                    for kwarg in env.Dictionary()
                    if isinstance(kwarg, basestring)
                    and kwarg.startswith('AUTOWIG_parser_')
                }
                for key, value in kwargs.items():
                    if isinstance(value, File):
                        kwargs[key] = str(value.abspath)
                if env['SYSTEM'] == 'win' and 'MSVC_VERSION' in env and not 'msvc_version' in kwargs:
                    kwargs['msvc_version'] = env['MSVC_VERSION']
                autowig.parser(
                    asg, [header.abspath for header in source],
                    flags=['-x', 'c++'] + env.subst(
                        '$CCFLAGS $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS'
                    ).split(),
                    **kwargs)
                AUTOWIG_CONTROLLER = env['AUTOWIG_CONTROLLER']
                if not AUTOWIG_CONTROLLER in autowig.controller:
                    filename = os.path.join(SITE_AUTOWIG, 'controller',
                                            AUTOWIG_CONTROLLER + '.py')
                    exec(
                        compile(open(filename, "rb").read(), filename, 'exec'),
                        globals(), locals())
                    autowig.controller[AUTOWIG_CONTROLLER] = locals(
                    )['controller']
                autowig.controller.plugin = AUTOWIG_CONTROLLER
                kwargs = {
                    kwarg[len('AUTOWIG_controller_'):]: env[kwarg]
                    for kwarg in env.Dictionary()
                    if isinstance(kwarg, basestring)
                    and kwarg.startswith('AUTOWIG_controller_')
                }
                for key, value in kwargs.items():
                    if isinstance(value, File):
                        kwargs[key] = str(value.abspath)
                asg = autowig.controller(asg, **kwargs)
                AUTOWIG_GENERATOR = env['AUTOWIG_GENERATOR']
                if not AUTOWIG_GENERATOR in autowig.generator:
                    filename = os.path.join(SITE_AUTOWIG, 'generator',
                                            AUTOWIG_GENERATOR + '.py')
                    exec(
                        compile(open(filename, "rb").read(), filename, 'exec'),
                        globals(), locals())
                    autowig.generator[AUTOWIG_GENERATOR] = locals(
                    )['generator']
                autowig.generator.plugin = AUTOWIG_GENERATOR
                kwargs = {
                    kwarg[len('AUTOWIG_generator_'):]: env[kwarg]
                    for kwarg in env.Dictionary()
                    if isinstance(kwarg, basestring)
                    and kwarg.startswith('AUTOWIG_generator_')
                }
                for key, value in kwargs.items():
                    if isinstance(value, File):
                        kwargs[key] = str(value.abspath)
                wrappers = autowig.generator(asg, **kwargs)
                wrappers.header.helder = env['AUTOWIG_HELDER']
                if not env['AUTOWIG_NO_WRAPPERS']:
                    wrappers.write()
                target = target[-1].abspath
                target_dir = os.path.abspath(os.path.join(target, os.pardir))
                if not os.path.exists(target_dir):
                    os.makedirs(target_dir)
                with open(target, 'wb') as filehandler:
                    pickle.dump(asg, filehandler)
                return None

            def BoostPythonWIG(env,
                               target,
                               sources,
                               module,
                               decorator=None,
                               parser='clanglite',
                               controller='default',
                               generator='boost_python_internal',
                               depends=[],
                               helder='std::shared_ptr',
                               **kwargs):
                #
                SITE_AUTOWIG = env['SITE_AUTOWIG']
                autowig_env = env.Clone()
                autowig_env['BUILDERS']['_BoostPythonWIG'] = Builder(
                    action=Action(
                        boost_python_builder,
                        'autowig: Generating Boost.Python interface ...'))
                autowig_env['AUTOWIG_DEPENDS'] = depends
                autowig_env['AUTOWIG_HELDER'] = helder
                for kwarg in kwargs:
                    autowig_env['AUTOWIG_' + kwarg] = kwargs[kwarg]
                autowig_env['AUTOWIG_generator_module'] = env.File(
                    module).srcnode()
                if decorator:
                    autowig_env['AUTOWIG_generator_decorator'] = env.File(
                        decorator).srcnode()
                targets = []
                if parser.endswith('.py'):
                    targets.append(
                        env.InstallAs(
                            os.path.join(SITE_AUTOWIG, 'parser',
                                         target + '.py'), parser))
                    parser = target
                autowig_env['AUTOWIG_PARSER'] = parser
                if controller.endswith('.py'):
                    targets.append(
                        env.InstallAs(
                            os.path.join(SITE_AUTOWIG, 'controller',
                                         target + '.py'), controller))
                    controller = target
                autowig_env['AUTOWIG_CONTROLLER'] = controller
                if generator.endswith('.py'):
                    targets.append(
                        env.InstallAs(
                            os.path.join(SITE_AUTOWIG, 'generator',
                                         target + '.py'), generator))
                    generator = target
                autowig_env['AUTOWIG_GENERATOR'] = generator

                targets.append(
                    autowig_env.File(
                        os.path.join(SITE_AUTOWIG, 'ASG', target + '.pkl')))
                for target in targets[:-1]:
                    autowig_env.Depends(targets[-1], target)

                if os.path.exists(targets[-1].abspath):
                    with open(targets[-1].abspath, 'rb') as filehandler:
                        autowig_env['AUTOWIG_ASG'] = pickle.load(filehandler)

                autowig_env._BoostPythonWIG(targets[-1], sources)

                return targets

            env.AddMethod(BoostPythonWIG)
예제 #29
0
def SetupBuildEnvironment(conf):
    AddOption('--optimization',
              dest='opt',
              action='store',
              default='debug',
              choices=['debug', 'production', 'coverage', 'profile'],
              help='optimization level: [debug|production|coverage|profile]')

    AddOption('--target',
              dest='target',
              action='store',
              choices=['i686', 'x86_64'])

    AddOption('--root', dest='install_root', action='store')
    AddOption('--prefix', dest='install_prefix', action='store')

    env = CheckBuildConfiguration(conf)

    env['OPT'] = GetOption('opt')
    env['TARGET_MACHINE'] = GetOption('target')
    env['INSTALL_PREFIX'] = GetOption('install_prefix')
    env['INSTALL_BIN'] = ''
    env['INSTALL_LIB'] = ''
    env['INSTALL_CONF'] = ''
    env['INSTALL_EXAMPLE'] = ''
    env['PYTHON_INSTALL_OPT'] = ''
    env['INSTALL_DOC'] = ''

    install_root = GetOption('install_root')
    if install_root:
        env['INSTALL_BIN'] = install_root
        env['INSTALL_LIB'] = install_root
        env['INSTALL_CONF'] = install_root
        env['INSTALL_EXAMPLE'] = install_root
        env['INSTALL_DOC'] = install_root
        env['PYTHON_INSTALL_OPT'] = '--root ' + install_root + ' '

    install_prefix = GetOption('install_prefix')
    if install_prefix:
        env['INSTALL_BIN'] += install_prefix
        env['INSTALL_LIB'] += install_prefix
        env['PYTHON_INSTALL_OPT'] += '--prefix ' + install_prefix + ' '
    elif install_root:
        env['INSTALL_BIN'] += '/usr'
        env['INSTALL_LIB'] += '/usr'
        env['PYTHON_INSTALL_OPT'] += '--prefix /usr '
    else:
        env['INSTALL_BIN'] += '/usr/local'

    env['INSTALL_BIN'] += '/bin'
    env['INSTALL_LIB'] += '/lib'
    env['INSTALL_CONF'] += '/etc/contrail'
    env['INSTALL_EXAMPLE'] += '/usr/share/contrail'
    env['INSTALL_DOC'] += '/usr/share/doc'

    distribution = platform.dist()[0]
    if distribution == "Ubuntu":
        env['PYTHON_INSTALL_OPT'] += '--install-layout=deb '

    if sys.platform == 'darwin':
        PlatformDarwin(env)
        env['ENV_SHLIB_PATH'] = 'DYLD_LIBRARY_PATH'
    else:
        env['ENV_SHLIB_PATH'] = 'LD_LIBRARY_PATH'

    if env.get('TARGET_MACHINE') == 'i686':
        env.Append(CCFLAGS='-march=' + 'i686')

    env['TOP_BIN'] = '#build/bin'
    env['TOP_INCLUDE'] = '#build/include'
    env['TOP_LIB'] = '#build/lib'

    opt_level = env['OPT']
    if opt_level == 'production':
        env.Append(CCFLAGS='-g -O3')
        env['TOP'] = '#build/production'
    elif opt_level == 'debug':
        env.Append(CCFLAGS=['-g', '-O0', '-DDEBUG'])
        env['TOP'] = '#build/debug'
    elif opt_level == 'profile':
        # Enable profiling through gprof
        env.Append(CCFLAGS=['-g', '-O3', '-DDEBUG', '-pg'])
        env.Append(LINKFLAGS=['-pg'])
        env['TOP'] = '#build/profile'
    elif opt_level == 'coverage':
        env.Append(CCFLAGS=['-g', '-O0', '--coverage'])
        env['TOP'] = '#build/coverage'
        env.Append(LIBS='gcov')

    env.Append(BUILDERS={'PyTestSuite': PyTestSuite})
    env.Append(BUILDERS={'TestSuite': TestSuite})
    env.Append(BUILDERS={'UnitTest': UnitTest})
    env.Append(BUILDERS={'GenerateBuildInfoCode': GenerateBuildInfoCode})
    env.Append(BUILDERS={'GenerateBuildInfoPyCode': GenerateBuildInfoPyCode})

    env.Append(BUILDERS={'setup_venv': setup_venv})
    env.Append(BUILDERS={'venv_add_pip_pkg': venv_add_pip_pkg})
    env.Append(BUILDERS={'venv_add_build_pkg': venv_add_build_pkg})

    env.AddMethod(ExtractCppFunc, "ExtractCpp")
    env.AddMethod(ExtractCFunc, "ExtractC")
    env.AddMethod(ExtractHeaderFunc, "ExtractHeader")
    env.AddMethod(ProtocGenDescFunc, "ProtocGenDesc")
    env.AddMethod(ProtocGenCppFunc, "ProtocGenCpp")
    env.AddMethod(SandeshGenOnlyCppFunc, "SandeshGenOnlyCpp")
    env.AddMethod(SandeshGenCppFunc, "SandeshGenCpp")
    env.AddMethod(SandeshGenCFunc, "SandeshGenC")
    env.AddMethod(SandeshGenPyFunc, "SandeshGenPy")
    env.AddMethod(ThriftGenCppFunc, "ThriftGenCpp")
    ThriftSconsEnvPyFunc(env)
    env.AddMethod(ThriftGenPyFunc, "ThriftGenPy")
    CreateIFMapBuilder(env)
    CreateTypeBuilder(env)

    PyTestSuiteCovBuilder = Builder(action=PyTestSuiteCov)
    env.Append(BUILDERS={'PyTestSuiteCov': PyTestSuiteCovBuilder})

    symlink_builder = Builder(action="ln -s ${SOURCE.file} ${TARGET.file}",
                              chdir=True)
    env.Append(BUILDERS={'Symlink': symlink_builder})

    env.AddMethod(UseSystemBoost, "UseSystemBoost")
    env.AddMethod(CppDisableExceptions, "CppDisableExceptions")
    env.AddMethod(CppEnableExceptions, "CppEnableExceptions")
    return env
예제 #30
0
from SCons.Script import AddOption

# override build directory
AddOption('--variant-dir',
          dest='variant_dir',
          nargs=1,
          type='string',
          action='store',
          metavar='DIR',
          help='build directory',
          default='.build')

# show variables
AddOption('--help-variables',
          dest='help_variables',
          action='store_true',
          help='show construction variables',
          default=False)