How to use the b2.util function in b2

To help you get started, we’ve selected a few b2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github boostorg / build / src / build / virtual_target.py View on Github external
self.cache_ [signature] = []

        for t in self.cache_ [signature]:
            a1 = t.action ()
            a2 = target.action ()

            # TODO: why are we checking for not result?
            if not result:
                if not a1 and not a2:
                    result = t
                else:
                    if a1 and a2 and a1.action_name () == a2.action_name () and a1.sources () == a2.sources ():
                        ps1 = a1.properties ()
                        ps2 = a2.properties ()
                        p1 = ps1.base () + ps1.free () +\
                            b2.util.set.difference(ps1.dependency(), ps1.incidental())
                        p2 = ps2.base () + ps2.free () +\
                            b2.util.set.difference(ps2.dependency(), ps2.incidental())
                        if p1 == p2:
                            result = t

        if not result:
            self.cache_ [signature].append (target)
            result = target

        # TODO: Don't append if we found pre-existing target?
        self.recent_targets_.append(result)
        self.all_targets_.append(result)

        return result
github boostorg / build / src / build_system.py View on Github external
# Here, user_config has value of None if nothing is explicitly
        # specified, and value of '' if user explicitly does not want
        # to load any user config.
        user_config = None
        for a in sys.argv:
            m = re.match("--user-config=(.*)$", a)
            if m:
                user_config = m.group(1)
                break

        if user_config is None:
            user_config = os.getenv("BOOST_BUILD_USER_CONFIG")

        # Special handling for the case when the OS does not strip the quotes
        # around the file name, as is the case when using Cygwin bash.
        user_config = b2.util.unquote(user_config)
        explicitly_requested = user_config

        if user_config is None:
            user_config = "user-config.jam"

        if user_config:
            if explicitly_requested:

                user_config = os.path.abspath(user_config)

                if debug_config:
                    print "notice: Loading explicitly specified user configuration file:"
                    print "    " + user_config

                    load_config('user-config', os.path.basename(user_config), [os.path.dirname(user_config)], True)
            else:
github clasp-developers / clasp / externals / boostbuild2 / src / build / virtual_target.py View on Github external
def add_prefix_and_suffix(specified_name, type, property_set):
    """Appends the suffix appropriate to 'type/property-set' combination
    to the specified name and returns the result."""

    property_set = b2.util.jam_to_value_maybe(property_set)

    suffix = ""
    if type:
        suffix = b2.build.type.generated_target_suffix(type, property_set)

    # Handle suffixes for which no leading dot is desired.  Those are
    # specified by enclosing them in <...>.  Needed by python so it
    # can create "_d.so" extensions, for example.
    if get_grist(suffix):
        suffix = ungrist(suffix)
    elif suffix:
        suffix = "." + suffix

    prefix = ""
    if type:
        prefix = b2.build.type.generated_target_prefix(type, property_set)
github vslavik / poedit / tools / build / src / build / virtual_target.py View on Github external
tag = ps.get("")

        if tag:

            if len(tag) > 1:
                get_manager().errors()(
                    """@rulename is present but is not the only  feature""")

            tag = tag[0]
            if callable(tag):
                self.name_ = tag(specified_name, self.type_, ps)
            else:
                if not tag[0] == '@':
                    self.manager_.errors()("""The value of the  feature must be '@rule-nane'""")

                exported_ps = b2.util.value_to_jam(ps, methods=True)
                self.name_ = b2.util.call_jam_function(
                    tag[1:], specified_name, self.type_, exported_ps)
                if self.name_:
                    self.name_ = self.name_[0]

        # If there's no tag or the tag rule returned nothing.
        if not tag or not self.name_:
            self.name_ = add_prefix_and_suffix(specified_name, self.type_, ps)
github dennisferron / LikeMagic-GameEngine / Common / boost_1_54_0 / tools / build / v2 / build / targets.py View on Github external
ok = 0
        for i in range(0, max_iterations):

            e = conditionals.evaluate_conditionals(current).all()[:]
        
            # Evaluate indirect conditionals.
            for i in indirect:
                i = b2.util.jam_to_value_maybe(i)
                if callable(i):
                    # This is Python callable, yeah.
                    e.extend(i(current))
                else:
                    # Name of bjam function. Because bjam is unable to handle
                    # list of Property, pass list of strings.
                    br = b2.util.call_jam_function(i[1:], [str(p) for p in current.all()])
                    if br:
                        e.extend(property.create_from_strings(br))

            if e == added_requirements:
                # If we got the same result, we've found final properties.
                ok = 1
                break
            else:
                # Oops, results of evaluation of conditionals has changed.
                # Also 'current' contains leftover from previous evaluation.
                # Recompute 'current' using initial properties and conditional
                # requirements.
                added_requirements = e
                current = context.refine(property_set.create(feature.expand(e)))

        if not ok:
github clasp-developers / clasp / externals / boostbuild2 / src / build / feature.py View on Github external
def minimize (properties):
    """ Given an expanded property set, eliminate all redundancy: properties
        which are elements of other (composite) properties in the set will
        be eliminated. Non-symmetric properties equal to default values will be
        eliminated, unless the override a value from some composite property.
        Implicit properties will be expressed without feature
        grist, and sub-property values will be expressed as elements joined
        to the corresponding main property.
    """    
    
    # remove properties implied by composite features
    components = []
    for property in properties:
        if __composite_properties.has_key (property):
            components.extend(__composite_properties[property])
    properties = b2.util.set.difference (properties, components)
    
    # handle subfeatures and implicit features

    # move subfeatures to the end of the list
    properties = [p for p in properties if not p.feature().subfeature()] +\
        [p for p in properties if p.feature().subfeature()]
    
    result = []
    while properties:
        p = properties[0]
        f = p.feature()
        
        # locate all subproperties of $(x[1]) in the property set
        subproperties = __select_subproperties (p, properties)
        
        if subproperties:
github stan-dev / math / lib / boost_1.69.0 / tools / build / src / build / virtual_target.py View on Github external
tag = ps.get("")

        if tag:

            if len(tag) > 1:
                get_manager().errors()(
                    """@rulename is present but is not the only  feature""")

            tag = tag[0]
            if callable(tag):
                self.name_ = tag(specified_name, self.type_, ps)
            else:
                if not tag[0] == '@':
                    self.manager_.errors()("""The value of the  feature must be '@rule-nane'""")

                exported_ps = b2.util.value_to_jam(ps, methods=True)
                self.name_ = b2.util.call_jam_function(
                    tag[1:], specified_name, self.type_, exported_ps)
                if self.name_:
                    self.name_ = self.name_[0]

        # If there's no tag or the tag rule returned nothing.
        if not tag or not self.name_:
            self.name_ = add_prefix_and_suffix(specified_name, self.type_, ps)
github stan-dev / math / lib / boost_1.69.0 / tools / build / src / util / option.py View on Github external
def get(name, default_value=None, implied_value=None):

    global options

    matches = b2.util.regex.transform(sys.argv, "--" + re.escape(name) + "=(.*)")
    if matches:
        return matches[-1]
    else:
        m = b2.util.regex.transform(sys.argv, "--(" + re.escape(name) + ")")
        if m and implied_value:
            return implied_value
        elif options.get(name) is not None:
            return options[name]
        else:
            return default_value
github boostorg / build / src / build / project.py View on Github external
def load_jamfile(self, dir, jamfile_module):
        """Load a Jamfile at the given directory. Returns nothing.
        Will attempt to load the file as indicated by the JAMFILE patterns.
        Effect of calling this rule twice with the same 'dir' is underfined."""

        # See if the Jamfile is where it should be.
        is_jamroot = False
        jamfile_to_load = b2.util.path.glob([dir], self.JAMROOT)
        if not jamfile_to_load:
            jamfile_to_load = self.find_jamfile(dir)
        else:
            if len(jamfile_to_load) > 1:
                get_manager().errors()("Multiple Jamfiles found at '%s'\n" +\
                                       "Filenames are: %s"
                                       % (dir, [os.path.basename(j) for j in jamfile_to_load]))

            is_jamroot = True
            jamfile_to_load = jamfile_to_load[0]

        dir = os.path.dirname(jamfile_to_load)
        if not dir:
            dir = "."

        self.used_projects[jamfile_module] = []