Esempio n. 1
0
    def setUp(self):
        self.opts_string = """
++ unix-linux-x86_64-3.2.0-gcc-4.7.2 _ KEY1 = VAL1
-- unix-linux-*-3.2.0-gcc dbg KEY2 = VAL2

# COMMENT
-- unix-linux-*-3.2.0-gcc- dbg KEY2 = VAL2
!! * dbg_mt_exc KEY3 = VAL3
>> unix- opt_mt KEY4 = VAL4_1 \
VAL4_2
        """
        self.opts_file = StringIO(self.opts_string)
        self.expected_vals = ((1, (optiontypes.OptionCommand.ADD,
                                   optiontypes.Uplid('unix', 'linux', 'x86_64',
                                                     '3.2.0', 'gcc', '4.7.2'),
                                   optiontypes.Ufid(), 'KEY1', 'VAL1')),
                              (2, (optiontypes.OptionCommand.INSERT,
                                   optiontypes.Uplid('unix', 'linux', '*',
                                                     '3.2.0', 'gcc'),
                                   optiontypes.Ufid(['dbg']), 'KEY2', 'VAL2')),
                              (5, (optiontypes.OptionCommand.INSERT,
                                   optiontypes.Uplid('unix', 'linux', '*',
                                                     '3.2.0', 'gcc'),
                                   optiontypes.Ufid(['dbg']), 'KEY2', 'VAL2')),
                              (6, (optiontypes.OptionCommand.OVERRIDE,
                                   optiontypes.Uplid(),
                                   optiontypes.Ufid(['dbg', 'mt',
                                                     'exc']), 'KEY3', 'VAL3')),
                              (7, (optiontypes.OptionCommand.APPEND,
                                   optiontypes.Uplid('unix'),
                                   optiontypes.Ufid(['opt', 'mt']), 'KEY4',
                                   'VAL4_1 VAL4_2')))
Esempio n. 2
0
def get_compilerinfos():
    os_type, os_name, cpu_type, os_ver = get_os_info()
    if os_type != 'windows':
        uplid = optiontypes.Uplid(os_type, os_name, cpu_type, os_ver)

        config_path = compilerinfo.get_user_config_path()
        user_compiler_infos = []
        if config_path:
            with open(config_path, 'r') as f:
                user_compiler_infos = compilerinfo.get_compilerinfos(
                                                     platform.node(), uplid, f)

        config_path = compilerinfo.get_system_config_path()
        system_compiler_infos = []
        if config_path:
            with open(config_path, 'r') as f:
                system_compiler_infos = compilerinfo.get_compilerinfos(
                                                     platform.node(), uplid, f)

        return user_compiler_infos + system_compiler_infos + compilerinfo.detect_installed_compilers(uplid)
    else:
        compiler_infos = []
        for v in msvcversions.versions:
            if not find_installdir(v.product_version):
                continue

            info = compilerinfo.CompilerInfo(
                'msvc', v.product_name.split()[-1], None, None, toolchain = "cl-default",
                desc = 'msvc-%s -- %s (Version %s)' %
                (v.product_name.split()[-1], v.product_name, v.product_version))
            compiler_infos.append(info)

        return compiler_infos
Esempio n. 3
0
    def test_get_compilerinfos1(self):

        uplid = optiontypes.Uplid('unix', 'linux', '*', '*', '*', '*')
        infos = compilerinfo.get_compilerinfos('m2', uplid, self.config_file)

        exp_infos = [
            compilerinfo.CompilerInfo('gcc', '4.1.2', '/usr/bin/gcc',
                                      '/usr/bin/g++')
        ]

        self.assertEqual(infos, exp_infos)
Esempio n. 4
0
    def test_get_compilerinfos3(self):

        uplid = optiontypes.Uplid('unix', 'aix', '*', '*', '*', '*')
        infos = compilerinfo.get_compilerinfos('blahblah', uplid,
                                               self.config_file)

        exp_infos = [
            compilerinfo.CompilerInfo('xlc', '11.1', '/a/b/c/xlc_r-11.1',
                                      '/d/e/f/xlC_r-11.1'),
            compilerinfo.CompilerInfo('xlc', '12.1', '/a/b/c/xlc_r-12.1',
                                      '/d/e/f/xlC_r-12.1'),
            compilerinfo.CompilerInfo('xlc', '12.2', '/a/b/c/xlc_r-12.2',
                                      '/d/e/f/xlC_r-12.2', '-qpath=/test/test')
        ]

        self.assertEqual(infos, exp_infos)
Esempio n. 5
0
    def test_get_compilerinfos2(self):

        uplid = optiontypes.Uplid('unix', 'linux', '*', '*', '*', '*')
        infos = compilerinfo.get_compilerinfos('m1', uplid, self.config_file)

        exp_infos = [
            compilerinfo.CompilerInfo('gcc', '4.9.2',
                                      '/opt/swt/install/gcc-4.9.2/bin/gcc',
                                      '/opt/swt/install/gcc-4.9.2/bin/g++'),
            compilerinfo.CompilerInfo('gcc', '4.3.5',
                                      '/opt/swt/install/gcc-4.3.5/bin/gcc',
                                      '/opt/swt/install/gcc-4.3.5/bin/g++'),
            compilerinfo.CompilerInfo('gcc', '4.1.2', '/usr/bin/gcc',
                                      '/usr/bin/g++')
        ]

        self.assertEqual(infos, exp_infos)
Esempio n. 6
0
def print_envs(options, info):
    ufid = optionsutil.make_ufid_from_cmdline_options(options)
    os_type, os_name, cpu_type, os_ver = get_os_info()

    uplid = optiontypes.Uplid(os_type, os_name, cpu_type, os_ver, info.type_,
                              info.version)

    print('Using compiler: %s' % info.description(), file=sys.stderr)
    print('Using ufid: %s' % ufid, file=sys.stderr)

    print('export BDE_WAF_UPLID=%s' % uplid)
    print('export BDE_WAF_UFID=%s' % ufid)
    id_str = '%s-%s' % (uplid, ufid)
    print('export BDE_WAF_BUILD_DIR="_build/%s"' % id_str)
    print('export WAFLOCK=".lock-waf-%s"' % id_str)

    if os_type != 'windows':
        print('export CXX=%s' % info.cxx_path)
        print('export CC=%s' % info.c_path)

    if info.flags:
        print('export BDE_WAF_COMP_FLAGS="%s"' % info.flags)
    else:
        print('unset BDE_WAF_COMP_FLAGS')

    if options.install_dir:
        install_dir = options.install_dir
    else:
        install_dir = _determine_installation_location(
            os.environ.get('PREFIX'), uplid)

    if install_dir:
        print('Using install directory: %s' % install_dir, file=sys.stderr)
        PREFIX = os.path.join(install_dir, id_str)
        if sysutil.unversioned_platform() == 'cygwin':
            PREFIX = sysutil.shell_command('cygpath -m "%s"' % PREFIX).rstrip()

        print('export PREFIX="%s"' % PREFIX)
        pkg_path = '%s/lib/pkgconfig' % PREFIX
        extra_pkg_path = os.environ.get('BDE_WAF_EXTRA_PKG_CONFIG_PATH')
        if extra_pkg_path:
            pkg_path += ':' + extra_pkg_path
        print('export PKG_CONFIG_PATH="%s"' % pkg_path)
Esempio n. 7
0
def get_compilerinfos():
    os_type, os_name, cpu_type, os_ver = get_os_info()
    if os_type != 'windows':
        uplid = optiontypes.Uplid(os_type, os_name, cpu_type, os_ver)
        compilerconfig_path = compilerinfo.get_config_path()

        with open(compilerconfig_path, 'r') as f:
            compiler_infos = compilerinfo.get_compilerinfos(
                platform.node(), uplid, f)
        return compiler_infos
    else:
        compiler_infos = []
        for v in msvcversions.versions:
            info = compilerinfo.CompilerInfo(
                'cl', v.compiler_version, None, None, None,
                'cl-%s -- %s (Version %s)' %
                (v.compiler_version, v.product_name, v.product_version))
            compiler_infos.append(info)

        return compiler_infos
Esempio n. 8
0
def print_envs(options, info):
    ufid = optionsutil.make_ufid_from_cmdline_options(options)
    os_type, os_name, cpu_type, os_ver = get_os_info()

    uplid = optiontypes.Uplid(os_type, os_name, cpu_type, os_ver, info.type_,
                              info.version)

    print("Using compiler: %s" % info.description(), file=sys.stderr)
    print("Using ufid: %s" % ufid, file=sys.stderr)

    print("export BDE_CMAKE_UPLID=%s" % uplid)
    print("export BDE_CMAKE_UFID=%s" % ufid)
    id_str = "%s-%s" % (uplid, ufid)

    if options.build_dir:
        print('export BDE_CMAKE_BUILD_DIR="%s"' % options.build_dir)
    else:
        print('export BDE_CMAKE_BUILD_DIR="_build/%s"' % id_str)

    if os_type != "windows":
        print("export CXX=%s" % info.cxx_path)
        print("export CC=%s" % info.c_path)
    else:
        print("export CXX=cl")
        print("export CC=cl")

    if info.toolchain:
        print("export BDE_CMAKE_TOOLCHAIN=toolchains/%s/%s" %
              (sysutil.unversioned_platform(), info.toolchain))
    else:
        print("export BDE_CMAKE_TOOLCHAIN=toolchains/%s/default" %
              sysutil.unversioned_platform())

    install_dir = options.install_dir if options.install_dir else "_install"

    print(
        "Using install directory: %s" % os.path.abspath(install_dir),
        file=sys.stderr,
    )
    print('export BDE_CMAKE_INSTALL_DIR="%s"' % os.path.abspath(install_dir))
Esempio n. 9
0
def make_uplid(ctx):
    """Create the Uplid representing the current build platform.

    Args:
        ctx (ConfigurationContext): The waf configuration context.

    Returns:
        effective_ufid, actual_ufid
    """
    os_type, os_name, cpu_type, os_ver = sysutil.get_os_info()
    comp_type, comp_ver = get_comp_info(ctx)

    actual_uplid = optiontypes.Uplid(os_type, os_name, cpu_type, os_ver,
                                     comp_type, comp_ver)

    env_uplid_str = os.getenv('BDE_WAF_UPLID')

    if env_uplid_str:
        effective_ufid = optiontypes.Uplid.from_str(env_uplid_str)
    else:
        effective_ufid = actual_uplid

    return effective_ufid, actual_uplid
Esempio n. 10
0
 def test_get_compilerinfo4(self):
     uplid = optiontypes.Uplid('unix', 'windows', '*', '*', '*', '*')
     infos = compilerinfo.get_compilerinfos('blahblah', uplid,
                                            self.config_file)
     self.assertEqual(infos, None)