コード例 #1
0
 def _verify_cycles_impl(self, digraph):
     cycles = graphutil.find_cycles(digraph)
     if len(cycles) == 0:
         self.log_end('ok')
     else:
         self.log_end('found cycle(s)')
         for cycle in cycles:
             logutil.info('CYCLE: ' + ','.join(cycle))
         self.is_success = False
コード例 #2
0
    def _store_option_rule(self, rule, debug_keys=[]):
        """Store the key and value of an option rule.
        """
        match = self._match_rule(rule)

        if rule.key in debug_keys:
            logutil.info('%s: %s' % (('Accept' if match else 'Ignore'),
                                     rule))
        if not match:
            return

        mc = self._OPT_INLINE_COMMAND_RE.search(rule.value)
        if mc:
            v = rule.value
            out = sysutil.shell_command(mc.group(1)).rstrip()
            rule.value = '%s"%s"%s' % (v[:mc.start(1) - 3], out,
                                       v[mc.end(1) + 3:])

        mc2 = self._OPT_INLINE_COMMAND_RE2.match(rule.value)
        if mc2:
            out = sysutil.shell_command(mc2.group(1)).rstrip()
            rule.value = out

        key = rule.key
        value = rule.value

        if key == 'BDE_COMPILER_FLAG':
            global DEFAULT_COMPILER
            DEFAULT_COMPILER = value

        if key not in self.results:
            self.results[key] = value
        else:
            orig = self.results[key]
            if rule.command == options.OptionCommand.ADD:
                if orig:
                    self.results[key] = orig + ' ' + value
                else:
                    self.results[key] = value
            elif rule.command == options.OptionCommand.INSERT:
                if orig:
                    self.results[key] = value + ' ' + orig
                else:
                    self.results[key] = value
            elif rule.command == options.OptionCommand.APPEND:
                self.results[key] = orig + value
            elif rule.command == options.OptionCommand.PREPEND:
                self.results[key] = value + orig
            elif rule.command == options.OptionCommand.OVERRIDE:
                self.results[key] = value

        if rule.key in debug_keys:
            logutil.info('Update: %s -> %s\n' % (rule.key,
                                                 self.results[rule.key]))
コード例 #3
0
    def evaluate(self, debug_keys=[]):
        """Evaluate stored options.
        """

        def evaluate_key(key):
            if key in self.results:
                self.results[key] = re.sub(
                    r'(\$\((\w+)\))',
                    lambda m: evaluate_key(m.group(2)),
                    self.results[key])
                return self.results[key]
            else:
                return ''

        for key in self.results:
            self.results[key] = evaluate_key(key)
            if key in debug_keys:
                logutil.info('Evaluated value: %s: %s' % (key,
                                                          self.results[key]))
コード例 #4
0
    def load_normal_package(package_name, oe):
        package = repo_context.packages[package_name]
        int_oe = copy.deepcopy(oe)
        int_oe.store_option_rules(package.opts)
        int_oe.store_option_rules(package.cap)
        set_unit_loc(int_oe, package)

        if debug_keys:
            logutil.info('--Evaluating %s' % package_name)
        int_oe.evaluate(debug_keys)

        if int_oe.results.get('CAPABILITY') == 'NEVER':
            logutil.info('skipped %s' % package_name)
            return False

        if package.type_ == repounits.PackageType.PLUS:
            package_bc = buildconfig.PlusPackageBuildConfig()
        else:
            package_bc = buildconfig.NormalPackageBuildConfig()

        package_bc.name = package.name
        package_bc.path = package.path
        package_bc.dep = package.dep
        package_bc.type_ = package.type_
        package_bc.flags = get_build_flags_from_opts(build_flags_parser,
                                                     int_oe.results)
        package_bc.has_dums = package.has_dums

        if package.type_ == repounits.PackageType.PLUS:
            package_bc.headers = package.pt_extras.headers
            package_bc.cpp_sources = package.pt_extras.cpp_sources
            package_bc.cpp_tests = package.pt_extras.cpp_tests
            package_bc.c_tests = package.pt_extras.c_tests
        else:
            package_bc.components = package.components

        build_config.normal_packages[package_name] = package_bc
        return True
コード例 #5
0
    def load_normal_package(package_name, oe):
        package = repo_context.packages[package_name]
        int_oe = copy.deepcopy(oe)
        int_oe.store_option_rules(package.opts)
        int_oe.store_option_rules(package.cap)
        set_unit_loc(int_oe, package)

        if debug_keys:
            logutil.info('--Evaluating %s' % package_name)
        int_oe.evaluate(debug_keys)

        if int_oe.results.get('CAPABILITY') == 'NEVER':
            logutil.info('skipped %s' % package_name)
            return False

        if package.type_ == repounits.PackageType.PLUS:
            package_bc = buildconfig.PlusPackageBuildConfig()
        else:
            package_bc = buildconfig.NormalPackageBuildConfig()

        package_bc.name = package.name
        package_bc.path = package.path
        package_bc.dep = package.dep
        package_bc.type_ = package.type_
        package_bc.flags = get_build_flags_from_opts(build_flags_parser,
                                                     int_oe.results)
        package_bc.has_dums = package.has_dums

        if package.type_ == repounits.PackageType.PLUS:
            package_bc.headers = package.pt_extras.headers
            package_bc.cpp_sources = package.pt_extras.cpp_sources
            package_bc.cpp_tests = package.pt_extras.cpp_tests
            package_bc.c_tests = package.pt_extras.c_tests
        else:
            package_bc.components = package.components

        build_config.normal_packages[package_name] = package_bc
        return True
コード例 #6
0
    def load_uor(uor_name):
        # Preserve the existing behavior of loading defs, opts and cap files as
        # bde_build:
        #
        # - Exported options of an UOR: read the defs files of its dependencies
        #   follow by itself. The files of the dependencies should be read in
        #   topological order, if the order of certain dependencies are
        #   ambiguous, order them first by dependency levels, and then by their
        #   name.
        #
        # - Internal options of an UOR: read the defs files in the same way,
        #   followed by its own opts file.

        dep_levels = graphutil.levelize(uor_dep_graph,
                                        uor_dep_graph[uor_name])

        oe = copy.deepcopy(def_oe)
        # We load options in levelized order instead of any topological order
        # to preserve the behavior with bde_build (older version of the build
        # tool).
        for level in dep_levels:
            for dep_name in sorted(level):
                if dep_name not in build_config.external_dep and \
                   dep_name not in build_config.third_party_packages:
                    dep_uor = uor_map[dep_name]
                    oe.store_option_rules(dep_uor.cap)
                    oe.store_option_rules(dep_uor.defs)

        uor = uor_map[uor_name]
        if uor_name in repo_context.package_groups:
            uor_bc = buildconfig.PackageGroupBuildConfig()
        else:
            uor_bc = buildconfig.SaPackageBuildConfig()
        uor_bc.name = uor.name
        uor_bc.path = uor.path
        uor_bc.doc = uor.doc
        uor_bc.version = uor.version
        uor_bc.dep = uor.dep - build_config.external_dep
        uor_bc.external_dep = uor.dep & build_config.external_dep

        oe.store_option_rules(uor.cap)
        oe.store_option_rules(uor.defs)
        set_unit_loc(oe, uor)

        # Evaluate export options.
        export_oe = copy.deepcopy(oe)
        export_oe.evaluate()

        if export_oe.results.get('CAPABILITY') == 'NEVER':
            logutil.info('skipped %s' % uor_name)
            return

        # Evaluate internal options.
        int_oe = copy.deepcopy(oe)
        int_oe.store_option_rules(uor.opts)

        # Copy unevaluted internal options to be used by packages within
        # package groups.
        int_oe_copy = copy.deepcopy(int_oe)

        if debug_keys:
            logutil.info('--Evaluating %s' % uor_name)
        int_oe.evaluate(debug_keys)

        uor_bc.flags = get_build_flags_from_opts(
            build_flags_parser, int_oe.results, export_oe.results)

        if uor_name in repo_context.package_groups:
            load_package_group(uor, uor_bc, int_oe_copy)
        elif uor_name in repo_context.packages:
            load_sa_package(uor, uor_bc)
コード例 #7
0
    def load_uor(uor_name):
        # Preserve the existing behavior of loading defs, opts and cap files as
        # bde_build:
        #
        # - Exported options of an UOR: read the defs files of its dependencies
        #   follow by itself. The files of the dependencies should be read in
        #   topological order, if the order of certain dependencies are
        #   ambiguous, order them first by dependency levels, and then by their
        #   name.
        #
        # - Internal options of an UOR: read the defs files in the same way,
        #   followed by its own opts file.

        dep_levels = graphutil.levelize(uor_dep_graph, uor_dep_graph[uor_name])

        oe = copy.deepcopy(def_oe)
        # We load options in levelized order instead of any topological order
        # to preserve the behavior with bde_build (older version of the build
        # tool).
        for level in dep_levels:
            for dep_name in sorted(level):
                if dep_name not in build_config.external_dep and \
                   dep_name not in build_config.third_party_packages:
                    dep_uor = uor_map[dep_name]
                    oe.store_option_rules(dep_uor.cap)
                    oe.store_option_rules(dep_uor.defs)

        uor = uor_map[uor_name]
        if uor_name in repo_context.package_groups:
            uor_bc = buildconfig.PackageGroupBuildConfig()
        else:
            uor_bc = buildconfig.SaPackageBuildConfig()
        uor_bc.name = uor.name
        uor_bc.path = uor.path
        uor_bc.doc = uor.doc
        uor_bc.version = uor.version
        uor_bc.dep = uor.dep - build_config.external_dep
        uor_bc.external_dep = uor.dep & build_config.external_dep

        oe.store_option_rules(uor.cap)
        oe.store_option_rules(uor.defs)
        set_unit_loc(oe, uor)

        # Evaluate export options.
        export_oe = copy.deepcopy(oe)
        export_oe.evaluate()

        if export_oe.results.get('CAPABILITY') == 'NEVER':
            logutil.info('skipped %s' % uor_name)
            return

        # Evaluate internal options.
        int_oe = copy.deepcopy(oe)
        int_oe.store_option_rules(uor.opts)

        # Copy unevaluted internal options to be used by packages within
        # package groups.
        int_oe_copy = copy.deepcopy(int_oe)

        if debug_keys:
            logutil.info('--Evaluating %s' % uor_name)
        int_oe.evaluate(debug_keys)

        uor_bc.flags = get_build_flags_from_opts(build_flags_parser,
                                                 int_oe.results,
                                                 export_oe.results)

        if uor_name in repo_context.package_groups:
            load_package_group(uor, uor_bc, int_oe_copy)
        elif uor_name in repo_context.packages:
            load_sa_package(uor, uor_bc)