Ejemplo 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')))
Ejemplo n.º 2
0
def make_ufid_from_cmdline_options(opts):
    """Create an Ufid from the specified command-line options.

    Args:
        opts (dict): The specified command-line options.

    Returns:
        An Ufid object.

    Raises:
        InvalidUfidError on invalid UFID.
    """

    if opts.ufid:
        ufid = optiontypes.Ufid.from_str(opts.ufid)
        if not optiontypes.Ufid.is_valid(ufid.flags):
            raise blderror.InvalidUfidError(
                'The UFID, "%s", is invalid.  Each part of a UFID must be '
                'in the following list of valid flags: %s.' %
                (opts.ufid, ", ".join(
                    sorted(optiontypes.Ufid.VALID_FLAGS.keys()))))
        return ufid

    ufid_map = {
        'abi_bits': {
            '64': '64'
        },
        'build_type': {
            'debug': 'dbg',
            'release': 'opt'
        },
        'safe': {
            True: 'safe'
        },
        'safe2': {
            True: 'safe2'
        },
        'cpp_std': {
            '11': 'cpp11'
        },
        'noexception': {
            False: 'exc'
        },
        'library_type': {
            'shared': 'shr'
        }
    }

    flags = []
    for opt in ufid_map:
        attr = getattr(opts, opt, None)
        if attr is not None:
            if attr in ufid_map[opt]:
                flags.append(ufid_map[opt][attr])

    # always use mt
    flags.append('mt')

    return optiontypes.Ufid(flags)
Ejemplo n.º 3
0
def make_ufid_from_cmdline_options(opts):
    """Create an Ufid from the specified command-line options.

    Args:
        opts (dict): The specified command-line options.

    Returns:
        An Ufid object.

    Raises:
        InvalidUfidError on invalid UFID.
    """

    if opts.ufid:
        ufid = optiontypes.Ufid.from_str(opts.ufid)
        if not optiontypes.Ufid.is_valid(ufid.flags):
            raise blderror.InvalidUfidError(
                'The UFID, "%s", is invalid.  Each part of a UFID must be '
                'in the following list of valid flags: %s.' %
                (opts.ufid, ", ".join(sorted(
                    optiontypes.Ufid.VALID_FLAGS.keys()))))
        return ufid

    ufid_map = {
        'abi_bits': {'64': ['64']},
        'build_type': {'Debug':          ['dbg'],
                       'Release':        ['opt'],
                       'RelWithDebInfo': ['opt', 'dbg' ]},
        'safe': {True: ['safe']},
        'safe2': {True: ['safe2']},
        'assert_level': {'aopt':  ['aopt'],
                         'adbg':  ['adbg'],
                         'asafe': ['asafe'],
                         'anone': ['anone']},
        'review_level': {'ropt':  ['ropt'],
                         'rdbg':  ['rdbg'],
                         'rsafe': ['rsafe'],
                         'rnone': ['rnone']},
        'cpp_std': {'03': ['cpp03'], '11': ['cpp11'], '14': ['cpp14'], '17': ['cpp17']},
        'noexception': {False: ['exc']},
        'library_type': {'shared': ['shr']}
        }

    # always use mt
    flags = ['mt']
    for opt in ufid_map:
        attr = getattr(opts, opt, None)
        if attr is not None:
            if attr in ufid_map[opt]:
                flags.extend(ufid_map[opt][attr])

    return optiontypes.Ufid(flags)
Ejemplo n.º 4
0
    def configure(self):
        self.ctx.msg('Prefix', self.ctx.env['PREFIX'])
        if self.uplid == self.actual_uplid:
            self.ctx.msg('Uplid', self.uplid)
        else:
            self.ctx.msg('Uplid - effective (this is *used*):',
                         str(self.uplid) + ' (from BDE_WAF_UPLID)',
                         color='YELLOW')
            self.ctx.msg('Uplid - actual (this is *not* used):',
                         self.actual_uplid, color='YELLOW')

        if os.getenv('BDE_WAF_UFID'):
            self.ctx.msg('Ufid',
                         str(self.ufid) + ' (from BDE_WAF_UFID)')
        else:
            self.ctx.msg('Ufid', self.ufid)

        if self.ctx.options.verbose >= 1:
            self.ctx.msg('OS type', self.uplid.os_type)
            self.ctx.msg('OS name', self.uplid.os_name)
            self.ctx.msg('CPU type', self.uplid.cpu_type)
            self.ctx.msg('OS version', self.uplid.os_ver)
            self.ctx.msg('Compiler type', self.uplid.comp_type)
            self.ctx.msg('Compiler version', self.uplid.comp_ver)

        loader = repocontextloader.RepoContextLoader(self.ctx.path.abspath())
        loader.load()

        self.repo_context = loader.repo_context

        if self.ctx.options.verify:
            self._verify()

        build_flags_parser = buildflagsparser.BuildFlagsParser(
            self.ctx.env['SHLIB_MARKER'],
            self.ctx.env['STLIB_MARKER'],
            self.ctx.env['LIB_ST'].replace('.', '\.').replace(
                '%s', r'([^ =]+)$'),
            self.ctx.env['LIBPATH_ST'].replace('.', '\.').replace(
                '%s', r'([^ =]+)'),
            self.ctx.env['CPPPATH_ST'].replace('.', '\.').replace(
                '%s', r'([^ =]+)'),
            '/D' if self.uplid.comp_type == 'cl' else '-D')

        default_rules = optionsutil.get_default_option_rules()

        # Enable -Werror for building .cpp files (but not .t.cpp) if --werror
        # is enabled.
        if self.ctx.options.werror == 'cpp':
            default_rules.append(optiontypes.OptionRule(
                optiontypes.OptionCommand.ADD,
                optiontypes.Uplid.from_str('*-*-*-*-gcc-*'),
                optiontypes.Ufid(),
                'COMPONENT_BDEBUILD_CXXFLAGS',
                '-Werror'))
            default_rules.append(optiontypes.OptionRule(
                optiontypes.OptionCommand.ADD,
                optiontypes.Uplid.from_str('*-*-*-*-clang-*'),
                optiontypes.Ufid(),
                'COMPONENT_BDEBUILD_CXXFLAGS',
                '-Werror'))

        debug_opt_keys = self.ctx.options.debug_opt_keys.split(',') if \
            self.ctx.options.debug_opt_keys is not None else []
        self.build_config = buildconfigfactory.make_build_config(
            self.repo_context, build_flags_parser, self.uplid, self.ufid,
            default_rules, debug_opt_keys)

        def print_list(label, l):
            if len(l):
                self.ctx.msg(label, ' '.join([str(i) for i in l]))

        print_list('Configured package groups',
                   sorted(self.build_config.package_groups))
        print_list('Configured stand-alone packages',
                   sorted(self.build_config.stdalone_packages))
        print_list('Configured third-party packages',
                   sorted(self.build_config.third_party_dirs))
        print_list('Loading external dependencies',
                   sorted(self.build_config.external_dep))
        self._configure_external_libs()

        if self.build_config.soname_overrides:
            for uor_name in self.build_config.soname_overrides:
                self.ctx.msg('Override SONAME for %s' % uor_name,
                             self.build_config.soname_overrides[uor_name])

        self.install_config = installconfig.InstallConfig(
            self.ufid,
            self.ctx.options.use_dpkg_install,
            self.ctx.options.use_flat_include_dir,
            self.ctx.options.libdir,
            self.ctx.options.bindir,
            self.ctx.options.lib_suffix)

        # The .pc files should be UFID neutral when installed to the DPKG
        # environment in Bloomberg.  I.e., a single .pc file supports multiple
        # UFID-specific types of a library.  By default, the installed .pc file
        # points to the release library.  A client can select a different
        # library type (e.g., dbg_mt_exc_safe) by prepending an -L linker flag
        # pointing to that particular type.  Here, we remove exported macro
        # definitions that are specific to any single UFID library type.
        if (self.ctx.options.use_dpkg_install and
                'bsl' in self.build_config.package_groups):
            pg = self.build_config.package_groups['bsl']
            remove_flags = []
            for f in pg.flags.export_flags:
                if (f.find('BDE_BUILD_TARGET') != -1 or
                        f.find('NDEBUG') != -1):
                    remove_flags.append(f)
            for f in remove_flags:
                pg.flags.export_flags.remove(f)

        self.ctx.msg('Use flat include directory',
                     'yes' if self.install_config.is_flat_include else 'no')
        self.ctx.msg('Lib install directory', self.install_config.lib_dir)
        self.ctx.msg('Pkg-config install directory',
                     self.install_config.pc_dir)
        if self.install_config.lib_suffix:
            self.ctx.msg('Lib name suffix', self.install_config.lib_suffix)

        num_uors = len(self.build_config.package_groups) + \
            len(self.build_config.stdalone_packages) + \
            len(self.build_config.third_party_dirs)
        num_inner_packages = len(self.build_config.inner_packages)
        num_components = 0
        for c in map(buildconfigutil.count_components_in_package,
                     list(self.build_config.inner_packages.values()) +
                     list(self.build_config.stdalone_packages.values())):
            num_components += c

        print_list('# UORs, inner packages, and components',
                   (num_uors, num_inner_packages, num_components))

        if self.ctx.options.verbose >= 2:
            self.ctx.msg('Build configuration details', self.build_config)

        self._save()
Ejemplo n.º 5
0
def make_ufid_from_cmdline_options(opts):
    """Create an Ufid from the specified command-line options.

    Args:
        opts (dict): The specified command-line options.

    Returns:
        An Ufid object.

    Raises:
        InvalidUfidError on invalid UFID.
    """

    if opts.ufid:
        ufid = optiontypes.Ufid.from_str(opts.ufid)
        if not optiontypes.Ufid.is_valid(ufid.flags):
            raise blderror.InvalidUfidError(
                'The UFID, "%s", is invalid.  Each part of a UFID must be '
                "in the following list of valid flags: %s." % (
                    opts.ufid,
                    ", ".join(sorted(optiontypes.Ufid.VALID_FLAGS.keys())),
                ))
        return ufid

    ufid_map = {
        "abi_bits": {
            "64": ["64"]
        },
        "build_type": {
            "Debug": ["dbg"],
            "Release": ["opt"],
            "RelWithDebInfo": ["opt", "dbg"],
        },
        "safe": {
            True: ["safe"]
        },
        "safe2": {
            True: ["safe2"]
        },
        "assert_level": {
            "aopt": ["aopt"],
            "adbg": ["adbg"],
            "asafe": ["asafe"],
            "anone": ["anone"],
        },
        "review_level": {
            "ropt": ["ropt"],
            "rdbg": ["rdbg"],
            "rsafe": ["rsafe"],
            "rnone": ["rnone"],
        },
        "sanitizer": {
            "asan": ["asan"],
            "msan": ["msan"],
            "tsan": ["tsan"],
            "ubsan": ["ubsan"],
        },
        "fuzz": {
            True: ["fuzz"]
        },
        "cpp_std": {
            "03": ["cpp03"],
            "11": ["cpp11"],
            "14": ["cpp14"],
            "17": ["cpp17"],
            "20": ["cpp20"],
        },
        "noexception": {
            False: ["exc"]
        },
        "library_type": {
            "shared": ["shr"]
        },
    }

    # always use mt
    flags = ["mt"]
    for opt in ufid_map:
        attr = getattr(opts, opt, None)
        if attr is not None:
            if attr in ufid_map[opt]:
                flags.extend(ufid_map[opt][attr])

    return optiontypes.Ufid(flags)