예제 #1
0
def __validate1 (property):
    """ Exit with error if property is not valid.
    """        
    msg = None

    f = get_grist (property)
    if f:
        value = get_value (property)

        if not feature.valid (f):
            f = ungrist (get_grist (property)) # Ungrist for better error messages
            msg = "Unknown feature '%s'" % f

        elif value and not 'free' in feature.attributes (f):
            feature.validate_value_string (f, value)

        elif not value:
            f = ungrist (get_grist (property)) # Ungrist for better error messages
            msg = "No value specified for feature '%s'" % f

    else:
        f = feature.implied_feature (property)
        feature.validate_value_string (f, property)

    if msg:
        # FIXME: don't use globals like this. Import here to
        # break circular dependency.
        from b2.manager import get_manager
        get_manager().errors()("Invalid property '%s': %s" % (property, msg))
예제 #2
0
파일: stage.py 프로젝트: Bandeira/sps
def install(name, sources, requirements=[], default_build=[], usage_requirements=[]):

    requirements = requirements[:]
    # Unless the user has explicitly asked us to hardcode dll paths, add
    # <hardcode-dll-paths>false in requirements, to override default value.
    if not "<hardcode-dll-paths>true" in requirements:
        requirements.append("<hardcode-dll-paths>false")

    if any(r.startswith("<tag>") for r in requirements):
        get_manager().errors()("The <tag> property is not allowed for the 'install' rule")

    from b2.manager import get_manager

    t = get_manager().targets()

    project = get_manager().projects().current()

    return t.main_target_alternative(
        InstallTargetClass(
            name,
            project,
            t.main_target_sources(sources, name),
            t.main_target_requirements(requirements, project),
            t.main_target_default_build(default_build, project),
            t.main_target_usage_requirements(usage_requirements, project),
        )
    )
예제 #3
0
    def determine_output_name(self, sources):
        """Determine the name of the produced target from the
        names of the sources."""
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)

        # The simple case if when a name
        # of source has single dot. Then, we take the part before
        # dot. Several dots can be caused by:
        # - Using source file like a.host.cpp
        # - A type which suffix has a dot. Say, we can
        #   type 'host_cpp' with extension 'host.cpp'.
        # In the first case, we want to take the part till the last
        # dot. In the second case -- no sure, but for now take
        # the part till the last dot too.
        name = os.path.splitext(sources[0].name())[0]

        for s in sources[1:]:
            n2 = os.path.splitext(s.name())
            if n2 != name:
                get_manager().errors()(
                    "%s: source targets have different names: cannot determine target name"
                    % (self.id_))

        # Names of sources might include directory. We should strip it.
        return self.determine_target_name(sources[0].name())
예제 #4
0
파일: builtin.py 프로젝트: Beman/build
    def process (self, target, matches, binding):
       
        angle = regex.transform (matches, "<(.*)>")
        quoted = regex.transform (matches, '"(.*)"')

        g = str(id(self))
        b = os.path.normpath(os.path.dirname(binding[0]))
        
        # Attach binding of including file to included targets.
        # When target is directly created from virtual target
        # this extra information is unnecessary. But in other
        # cases, it allows to distinguish between two headers of the 
        # same name included from different places.      
        # We don't need this extra information for angle includes,
        # since they should not depend on including file (we can't
        # get literal "." in include path).
        g2 = g + "#" + b

        g = "<" + g + ">"
        g2 = "<" + g2 + ">"
        angle = [g + x for x in angle]
        quoted = [g2 + x for x in quoted]

        all = angle + quoted
        bjam.call("mark-included", target, all)

        engine = get_manager().engine()
        engine.set_target_variable(angle, "SEARCH", get_value(self.includes_))
        engine.set_target_variable(quoted, "SEARCH", [b] + get_value(self.includes_))
        
        # Just propagate current scanner to includes, in a hope
        # that includes do not change scanners. 
        get_manager().scanners().propagate(self, angle + quoted)
예제 #5
0
def make_test(target_type, sources, requirements, target_name=None):

    if not target_name:
        target_name = stem(os.path.basename(sources[0]))

    # Having periods (".") in the target name is problematic because the typed
    # generator will strip the suffix and use the bare name for the file
    # targets. Even though the location-prefix averts problems most times it
    # does not prevent ambiguity issues when referring to the test targets. For
    # example when using the XML log output. So we rename the target to remove
    # the periods, and provide an alias for users.
    real_name = target_name.replace(".", "~")

    project = get_manager().projects().current()
    # The <location-prefix> forces the build system for generate paths in the
    # form '$build_dir/array1.test/gcc/debug'. This is necessary to allow
    # post-processing tools to work.
    t = get_manager().targets().create_typed_target(
        type.type_from_rule_name(target_type), project, real_name, sources,
        requirements + ["<location-prefix>" + real_name + ".test"], [], [])

    # The alias to the real target, per period replacement above.
    if real_name != target_name:
        get_manager().projects().project_rules().all_names_["alias"](
            target_name, [t])

    # Remember the test (for --dump-tests). A good way would be to collect all
    # given a project. This has some technical problems: e.g. we can not call
    # this dump from a Jamfile since projects referred by 'build-project' are
    # not available until the whole Jamfile has been loaded.
    __all_tests.append(t)
    return t
예제 #6
0
파일: builtin.py 프로젝트: Beman/build
def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]):
    """The implementation of the 'lib' rule. Beyond standard syntax that rule allows
    simplified: 'lib a b c ;'."""

    if len(names) > 1:
        if any(r.startswith('<name>') for r in requirements):
            get_manager().errors()("When several names are given to the 'lib' rule\n" +
                                   "it is not allowed to specify the <name> feature.")

        if sources:
            get_manager().errors()("When several names are given to the 'lib' rule\n" +
                                   "it is not allowed to specify sources.")

    project = get_manager().projects().current()
    result = []

    for name in names:
        r = requirements[:]

        # Support " lib a ; " and " lib a b c ; " syntax.
        if not sources and not any(r.startswith("<name>") for r in requirements) \
           and not any(r.startswith("<file") for r in requirements):
            r.append("<name>" + name)

        result.append(targets.create_typed_metatarget(name, "LIB", sources,
                                                      r,
                                                      default_build,
                                                      usage_requirements))
    return result
예제 #7
0
파일: path.py 프로젝트: DesignD/build
def reverse(path):
    """Returns path2 such that `os.path.join(path, path2) == '.'`.
    `path` may not contain '..' or be rooted.

    Args:
        path (str): the path to reverse

    Returns:
        the string of the reversed path

    Example:

        >>> p1 = 'path/to/somewhere'
        >>> p2 = reverse('path/to/somewhere')
        >>> p2
        '../../..'
        >>> os.path.normpath(os.path.join(p1, p2))
        '.'
    """
    if is_rooted(path) or '..' in path:
        from b2.manager import get_manager
        get_manager().errors()(
            'reverse(path): path is either rooted or contains ".." in the path')
    if path == '.':
        return path
    path = os.path.normpath(path)
    # os.sep.join() is being used over os.path.join() due
    # to an extra '..' that is created by os.path.join()
    return os.sep.join('..' for t in path.split(os.sep))
예제 #8
0
def __ensure_type (targets):
    """ Ensures all 'targets' have types. If this is not so, exists with 
        error.
    """
    for t in targets:
        if not t.type ():
            get_manager().errors()("target '%s' has no type" % str (t))
예제 #9
0
    def process(self, target, matches, binding):

        target_path = os.path.normpath(os.path.dirname(binding[0]))
        bjam.call("mark-included", target, matches)

        get_manager().engine().set_target_variable(matches, "SEARCH", [target_path] + self.includes)
        get_manager().scanners().propagate(self, matches)
예제 #10
0
파일: type.py 프로젝트: boostorg/build
def register(type, suffixes=[], base_type=None):
    """ Registers a target type, possibly derived from a 'base-type'.
        If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
        Also, the first element gives the suffix to be used when constructing and object of
        'type'.
        type: a string
        suffixes: None or a sequence of strings
        base_type: None or a string
    """
    # Type names cannot contain hyphens, because when used as
    # feature-values they will be interpreted as composite features
    # which need to be decomposed.
    if __re_hyphen.search(type):
        raise BaseException('type name "%s" contains a hyphen' % type)

    # it's possible for a type to be registered with a
    # base type that hasn't been registered yet. in the
    # check for base_type below and the following calls to setdefault()
    # the key `type` will be added to __types. When the base type
    # actually gets registered, it would fail after the simple check
    # of "type in __types"; thus the check for "'base' in __types[type]"
    if type in __types and "base" in __types[type]:
        raise BaseException('Type "%s" is already registered.' % type)

    entry = __types.setdefault(type, {})
    entry["base"] = base_type
    entry.setdefault("derived", [])
    entry.setdefault("scanner", None)

    if base_type:
        __types.setdefault(base_type, {}).setdefault("derived", []).append(type)

    if len(suffixes) > 0:
        # Generated targets of 'type' will use the first of 'suffixes'
        # (this may be overriden)
        set_generated_target_suffix(type, [], suffixes[0])

        # Specify mapping from suffixes to type
        register_suffixes(suffixes, type)

    feature.extend("target-type", [type])
    feature.extend("main-target-type", [type])
    feature.extend("base-target-type", [type])

    if base_type:
        feature.compose("<target-type>" + type, [replace_grist(base_type, "<base-target-type>")])
        feature.compose("<base-target-type>" + type, ["<base-target-type>" + base_type])

    import b2.build.generators as generators

    # Adding a new derived type affects generator selection so we need to
    # make the generator selection module update any of its cached
    # information related to a new derived type being defined.
    generators.update_cached_information_with_a_new_type(type)

    # FIXME: resolving recursive dependency.
    from b2.manager import get_manager

    get_manager().projects().project_rules().add_rule_for_type(type)
예제 #11
0
def __ensure_type (targets):
    """ Ensures all 'targets' have types. If this is not so, exists with
        error.
    """
    assert is_iterable_typed(targets, virtual_target.VirtualTarget)
    for t in targets:
        if not t.type ():
            get_manager().errors()("target '%s' has no type" % str (t))
예제 #12
0
    def set_default(self, value):
        assert isinstance(value, basestring)
        for attr in ('free', 'optional'):
            if getattr(self, attr):
                get_manager().errors()('"{}" feature "<{}>" cannot have a default value.'
                                       .format(attr, self.name))

        self.default = value
예제 #13
0
def inherit(toolset, base):
    assert isinstance(toolset, basestring)
    assert isinstance(base, basestring)
    get_manager().projects().load_module(base, ['.']);

    inherit_generators(toolset, [], base)
    inherit_flags(toolset, base)
    inherit_rules(toolset, base)
예제 #14
0
def handle_input_files(input_files):
    if len(input_files) > 1:
        # Check that sorting made when creating property-set instance will not
        # change the ordering.
        if sorted(input_files) != input_files:
            get_manager().errors()("Names of input files must be sorted alphabetically\n" +
                                   "due to internal limitations")
    return ["<testing.input-file>" + f for f in input_files]
예제 #15
0
    def option(self, name, value):
        assert is_iterable(name) and isinstance(name[0], basestring)
        assert is_iterable(value) and isinstance(value[0], basestring)
        name = name[0]
        if not name in ["site-config", "user-config", "project-config"]:
            get_manager().errors()("The 'option' rule may be used only in site-config or user-config")

        option.set(name, value[0])
예제 #16
0
파일: notfile.py 프로젝트: Bandeira/sps
    def run(self, project, name, ps, sources):
        pass
        action_name = ps.get("action")[0]
        if action_name[0] == "@":
            action = virtual_target.Action(get_manager(), sources, action_name[1:], ps)
        else:
            action = virtual_target.Action(get_manager(), sources, "notfile.run", ps)

        return [get_manager().virtual_targets().register(virtual_target.NotFileTarget(name, project, action))]
예제 #17
0
def gcc_compile_cpp(targets, sources, properties):
    # Some extensions are compiled as C++ by default. For others, we need to
    # pass -x c++. We could always pass -x c++ but distcc does not work with it.
    extension = os.path.splitext (sources [0]) [1]
    lang = ''
    if not extension in ['.cc', '.cp', '.cxx', '.cpp', '.c++', '.C']:
        lang = '-x c++'
    get_manager().engine().set_target_variable (targets, 'LANG', lang)
    engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE'))
예제 #18
0
파일: message.py 프로젝트: Bandeira/sps
def message(name, *args):

    if type(name) == type([]):
        name = name[0]

    t = get_manager().targets()
    
    project = get_manager().projects().current()
        
    return t.main_target_alternative(MessageTargetClass(*((name, project) + args)))
예제 #19
0
def symlink(targets, sources):

    from b2.manager import get_manager
    t = get_manager().targets()
    p = get_manager().projects().current()

    return t.main_target_alternative(
        SymlinkTarget(p, targets,
                      # Note: inline targets are not supported for symlink, intentionally,
                      # since it's used to linking existing non-local targets.
                      sources))
예제 #20
0
def register(type, suffixes=[], base_type=None):
    """ Registers a target type, possibly derived from a 'base-type'. 
        If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
        Also, the first element gives the suffix to be used when constructing and object of
        'type'.
        type: a string
        suffixes: None or a sequence of strings
        base_type: None or a string
    """
    # Type names cannot contain hyphens, because when used as
    # feature-values they will be interpreted as composite features
    # which need to be decomposed.
    if __re_hyphen.search(type):
        raise BaseException('type name "%s" contains a hyphen' % type)

    if __types.has_key(type):
        raise BaseException('Type "%s" is already registered.' % type)

    entry = {}
    entry["base"] = base_type
    entry["derived"] = []
    entry["scanner"] = None
    __types[type] = entry

    if base_type:
        __types[base_type]["derived"].append(type)

    if len(suffixes) > 0:
        # Generated targets of 'type' will use the first of 'suffixes'
        # (this may be overriden)
        set_generated_target_suffix(type, [], suffixes[0])

        # Specify mapping from suffixes to type
        register_suffixes(suffixes, type)

    feature.extend("target-type", [type])
    feature.extend("main-target-type", [type])
    feature.extend("base-target-type", [type])

    if base_type:
        feature.compose("<target-type>" + type, replace_grist(base_type, "<base-target-type>"))
        feature.compose("<base-target-type>" + type, "<base-target-type>" + base_type)

    import b2.build.generators as generators

    # Adding a new derived type affects generator selection so we need to
    # make the generator selection module update any of its cached
    # information related to a new derived type being defined.
    generators.update_cached_information_with_a_new_type(type)

    # FIXME: resolving recursive dependency.
    from b2.manager import get_manager

    get_manager().projects().project_rules().add_rule_for_type(type)
예제 #21
0
파일: alias.py 프로젝트: Bandeira/sps
def alias(name, sources=[], requirements=[], default_build=[], usage_requirements=[]):

    project = get_manager().projects().current()
    targets = get_manager().targets()

    targets.main_target_alternative(AliasTarget(
        name, project,
        targets.main_target_sources(sources, name, no_renaming=True),
        targets.main_target_requirements(requirements or [], project),
        targets.main_target_default_build(default_build, project),
        targets.main_target_usage_requirements(usage_requirements or [], project)))
예제 #22
0
def create_from_string(s, allow_condition=False,allow_missing_value=False):
    assert isinstance(s, basestring)
    assert isinstance(allow_condition, bool)
    assert isinstance(allow_missing_value, bool)
    condition = []
    import types
    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException("Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()("Invalid property '%s' -- unknown feature" % s)
    else:
        if feature.valid(feature_name):
            f = feature.get(feature_name)
            value = get_value(s)
        else:
            # In case feature name is not known, it is wrong to do a hard error.
            # Feature sets change depending on the toolset. So e.g.
            # <toolset-X:version> is an unknown feature when using toolset Y.
            #
            # Ideally we would like to ignore this value, but most of
            # Boost.Build code expects that we return a valid Property. For this
            # reason we use a sentinel <not-applicable-in-this-context> feature.
            #
            # The underlying cause for this problem is that python port Property
            # is more strict than its Jam counterpart and must always reference
            # a valid feature.
            f = feature.get(__not_applicable_feature)
            value = s

        if not value and not allow_missing_value:
            get_manager().errors()("Invalid property '%s' -- no value specified" % s)


    if condition:
        condition = [create_from_string(x) for x in condition.split(',')]

    return Property(f, value, condition)
예제 #23
0
    def __adjust_name(self, specified_name):
        """Given the target name specified in constructor, returns the
        name which should be really used, by looking at the <tag> properties.
        The tag properties come in two flavour:
          - <tag>value,
          - <tag>@rule-name
        In the first case, value is just added to name
        In the second case, the specified rule is called with specified name,
        target type and properties and should return the new name.
        If not <tag> property is specified, or the rule specified by
        <tag> returns nothing, returns the result of calling
        virtual-target.add-suffix"""

        if self.action_:
            ps = self.action_.properties()
        else:
            ps = property_set.empty()

        # FIXME: I'm not sure how this is used, need to check with
        # Rene to figure out how to implement
        #~ We add ourselves to the properties so that any tag rule can get
        #~ more direct information about the target than just that available
        #~ through the properties. This is useful in implementing
        #~ name changes based on the sources of the target. For example to
        #~ make unique names of object files based on the source file.
        #~ --grafik
        #ps = property_set.create(ps.raw() + ["<target>%s" % "XXXX"])
        #ps = [ property-set.create [ $(ps).raw ] <target>$(__name__) ] ;

        tag = ps.get("<tag>")

        if tag:

            if len(tag) > 1:
                get_manager().errors()(
                    """<tag>@rulename is present but is not the only <tag> 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 <tag> 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)
예제 #24
0
파일: builtin.py 프로젝트: boostorg/build
    def process(self, target, matches, binding):
        # since it's possible for this function to be called
        # thousands to millions of times (depending on how many
        # header files there are), as such, there are some
        # optimizations that have been used here. Anything that
        # is slightly out of the ordinary for Python code
        # has been commented.
        angle = []
        quoted = []
        for match in matches:
            if "<" in match:
                angle.append(match.strip("<>"))
            elif '"' in match:
                quoted.append(match.strip('"'))

        g = id(self)
        b = os.path.normpath(os.path.dirname(binding[0]))

        # Attach binding of including file to included targets.
        # When target is directly created from virtual target
        # this extra information is unnecessary. But in other
        # cases, it allows to distinguish between two headers of the
        # same name included from different places.
        # We don't need this extra information for angle includes,
        # since they should not depend on including file (we can't
        # get literal "." in include path).
        # Note: string interpolation is slightly faster
        # than .format()
        g2 = "<%s#%s>" % (g, b)
        g = "<%s>" % g

        angle = [g + x for x in angle]
        quoted = [g2 + x for x in quoted]

        all = angle + quoted
        bjam.call("mark-included", target, all)

        # each include in self.includes_ looks something like this:
        #     <include>path/to/somewhere
        # calling get_value(include) is super slow,
        # calling .replace('<include>', '') is much faster
        # however, i[9:] is the fastest way of stripping off the "<include>"
        # substring.
        include_paths = [i[9:] for i in self.includes_]

        engine = get_manager().engine()
        engine.set_target_variable(angle, "SEARCH", include_paths)
        engine.set_target_variable(quoted, "SEARCH", [b] + include_paths)

        # Just propagate current scanner to includes, in a hope
        # that includes do not change scanners.
        get_manager().scanners().propagate(self, all)
예제 #25
0
def alias(name, sources, requirements=None, default_build=None, usage_requirements=None):
    project = get_manager().projects().current()
    targets = get_manager().targets()

    if default_build:
        default_build = default_build[0]

    targets.main_target_alternative(AliasTarget(
        name[0], project,
        targets.main_target_sources(sources, name),
        targets.main_target_requirements(requirements or [], project),
        targets.main_target_default_build(default_build, project),
        targets.main_target_usage_requirements(usage_requirements or [], project)))
예제 #26
0
파일: cast.py 프로젝트: Cabriter/abelkhan
def cast(name, type, sources, requirements, default_build, usage_requirements):

    from b2.manager import get_manager
    t = get_manager().targets()

    project = get_manager().projects().current()

    return t.main_target_alternative(
        CastTargetClass(name, project, type,
                        t.main_target_sources(sources, name),
                        t.main_target_requirements(requirements, project),
                        t.main_target_default_build(default_build, project),
                        t.main_target_usage_requirements(usage_requirements, project)))
예제 #27
0
    def register_actual_name(self, actual_name, virtual_target):
        assert isinstance(actual_name, basestring)
        assert isinstance(virtual_target, VirtualTarget)
        if self.actual_.has_key(actual_name):
            cs1 = self.actual_[actual_name].creating_subvariant()
            cs2 = virtual_target.creating_subvariant()
            cmt1 = cs1.main_target()
            cmt2 = cs2.main_target()

            action1 = self.actual_[actual_name].action()
            action2 = virtual_target.action()

            properties_added = []
            properties_removed = []
            if action1 and action2:
                p1 = action1.properties()
                p1 = p1.raw()
                p2 = action2.properties()
                p2 = p2.raw()

                properties_removed = set.difference(p1, p2)
                if not properties_removed:
                    properties_removed = "none"

                properties_added = set.difference(p2, p1)
                if not properties_added:
                    properties_added = "none"

            # FIXME: Revive printing of real location.
            get_manager().errors()(
                "Duplicate name of actual target: '%s'\n"
                "previous virtual target '%s'\n"
                "created from '%s'\n"
                "another virtual target '%s'\n"
                "created from '%s'\n"
                "added properties: '%s'\n"
                "removed properties: '%s'\n"
                % (
                    actual_name,
                    self.actual_[actual_name],
                    "loc",  # cmt1.location (),
                    virtual_target,
                    "loc",  # cmt2.location (),
                    properties_added,
                    properties_removed,
                )
            )

        else:
            self.actual_[actual_name] = virtual_target
예제 #28
0
파일: cast.py 프로젝트: Bandeira/sps
    def construct(name, source_targets, ps):
        result = []
        for s in source_targets:
            if not isinstance(s, virtual_targets.FileTarget):
                get_manager().errors()("Source to the 'cast' metatager is not a file")

            if s.action():
                get_manager().errors()("Only non-derived targets allowed as sources for 'cast'.")


            r = s.clone_with_different_type(self.type())
            result.append(get_manager().virtual_targets().register(r))

        return result
예제 #29
0
파일: rc.py 프로젝트: Cabriter/abelkhan
    def process(self, target, matches, binding):
        binding = binding[0]
        angle = regex.transform(matches, "#include[ ]*<([^<]+)>")
        quoted = regex.transform(matches, "#include[ ]*\"([^\"]+)\"")
        res = regex.transform(matches,
                              "[^ ]+[ ]+(BITMAP|CURSOR|FONT|ICON|MESSAGETABLE|RT_MANIFEST)" +\
                              "[ ]+(([^ \"]+)|\"([^\"]+)\")", [3, 4])

        # Icons and other includes may referenced as
        #
        # IDR_MAINFRAME ICON "res\\icon.ico"
        #
        # so we have to replace double backslashes to single ones.
        res = [ re.sub(r'\\\\', '/', match) for match in res if match is not None ]

        # CONSIDER: the new scoping rule seem to defeat "on target" variables.
        g = bjam.call('get-target-variable', target, 'HDRGRIST')[0]
        b = os.path.normpath(os.path.dirname(binding))

        # Attach binding of including file to included targets.
        # When target is directly created from virtual target
        # this extra information is unnecessary. But in other
        # cases, it allows to distinguish between two headers of the
        # same name included from different places.
        # We don't need this extra information for angle includes,
        # since they should not depend on including file (we can't
        # get literal "." in include path).
        g2 = g + "#" + b

        g = "<" + g + ">"
        g2 = "<" + g2 + ">"
        angle = [g + x for x in angle]
        quoted = [g2 + x for x in quoted]
        res = [g2 + x for x in res]

        all = angle + quoted

        bjam.call('mark-included', target, all)

        engine = get_manager().engine()

        engine.add_dependency(target, res)
        bjam.call('NOCARE', all + res)
        engine.set_target_variable(angle, 'SEARCH', [utility.get_value(inc) for inc in self.includes])
        engine.set_target_variable(quoted, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes])
        engine.set_target_variable(res, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes])

        # Just propagate current scanner to includes, in a hope
        # that includes do not change scanners.
        get_manager().scanners().propagate(self, angle + quoted)
예제 #30
0
파일: property.py 프로젝트: Bandeira/sps
def translate_indirect(properties, context_module):
    """Assumes that all feature values that start with '@' are
    names of rules, used in 'context-module'. Such rules can be
    either local to the module or global. Qualified local rules
    with the name of the module."""
    result = []
    for p in properties:
        if p.value()[0] == "@":
            q = qualify_jam_action(p.value()[1:], context_module)
            get_manager().engine().register_bjam_action(q)
            result.append(Property(p.feature(), "@" + q, p.condition()))
        else:
            result.append(p)

    return result
예제 #31
0
 def construct(self, name, source_targets, property_set):
     action_name = property_set.get("<action>")[0]
     action = Action(get_manager(), source_targets, action_name[1:], property_set)
     target = FileTarget(self.name(), type.type(self.name()),
                         self.project(), action, exact=True)
     return [b2.build.property_set.empty(),
             [self.project().manager().virtual_targets().register(target)]]
예제 #32
0
def cast(name, type, sources, requirements, default_build, usage_requirements):

    from b2.manager import get_manager
    t = get_manager().targets()

    project = get_manager().projects().current()

    real_type = type_.type_from_rule_name(type)
    if not real_type:
        real_type = type
    return t.main_target_alternative(
        CastTargetClass(
            name, project, real_type, t.main_target_sources(sources, name),
            t.main_target_requirements(requirements, project),
            t.main_target_default_build(default_build, project),
            t.main_target_usage_requirements(usage_requirements, project)))
예제 #33
0
def actual_clean_targets(targets):

    # Construct a list of projects explicitly detected as targets on this build
    # system run. These are the projects under which cleaning is allowed.
    for t in targets:
        if isinstance(t, b2.build.targets.ProjectTarget):
            project_targets.append(t.project_module())

    # Construct a list of targets explicitly detected on this build system run
    # as a result of building main targets.
    targets_to_clean = set()
    for t in results_of_main_targets:
        # Do not include roots or sources.
        targets_to_clean.update(virtual_target.traverse(t))

    to_clean = []
    for t in get_manager().virtual_targets().all_targets():

        # Remove only derived targets.
        if t.action():
            p = t.project()
            if t in targets_to_clean or should_clean_project(
                    p.project_module()):
                to_clean.append(t)

    return [t.actualize() for t in to_clean]
예제 #34
0
def make(target_name,
         sources,
         generating_rule,
         requirements=None,
         usage_requirements=None):

    target_name = target_name[0]
    generating_rule = generating_rule[0]
    if generating_rule[0] != '@':
        generating_rule = '@' + generating_rule

    if not requirements:
        requirements = []

    requirements.append("<action>%s" % generating_rule)

    m = get_manager()
    targets = m.targets()
    project = m.projects().current()
    engine = m.engine()
    engine.register_bjam_action(generating_rule)

    targets.main_target_alternative(
        MakeTarget(
            target_name, project,
            targets.main_target_sources(sources, target_name),
            targets.main_target_requirements(requirements, project),
            targets.main_target_default_build([], project),
            targets.main_target_usage_requirements(usage_requirements or [],
                                                   project)))
예제 #35
0
def gcc_link_dll(targets, sources, properties):
    engine = get_manager().engine()
    engine.set_target_variable(targets, 'SPACE', ' ')
    engine.set_target_variable(targets, 'JAM_SEMAPHORE',
                               '<s>gcc-link-semaphore')
    engine.set_target_variable(targets, "HAVE_SONAME", HAVE_SONAME)
    engine.set_target_variable(targets, "SONAME_OPTION", SONAME_OPTION)
예제 #36
0
def gcc_archive(targets, sources, properties):
    # Always remove archive and start again. Here's rationale from
    #
    # Andre Hentz:
    #
    # I had a file, say a1.c, that was included into liba.a. I moved a1.c to
    # a2.c, updated my Jamfiles and rebuilt. My program was crashing with absurd
    # errors. After some debugging I traced it back to the fact that a1.o was
    # *still* in liba.a
    #
    # Rene Rivera:
    #
    # Originally removing the archive was done by splicing an RM onto the
    # archive action. That makes archives fail to build on NT when they have
    # many files because it will no longer execute the action directly and blow
    # the line length limit. Instead we remove the file in a different action,
    # just before building the archive.
    clean = targets[0] + '(clean)'
    bjam.call('TEMPORARY', clean)
    bjam.call('NOCARE', clean)
    engine = get_manager().engine()
    engine.set_target_variable(
        'LOCATE', clean, bjam.call('get-target-variable', targets, 'LOCATE'))
    engine.add_dependency(clean, sources)
    engine.add_dependency(targets, clean)
    engine.set_update_action('common.RmTemps', clean, targets)
예제 #37
0
def gcc_link(targets, sources, properties):
    engine = get_manager().engine()
    engine.set_target_variable(targets, 'SPACE', ' ')
    # Serialize execution of the 'link' action, since running N links in
    # parallel is just slower. For now, serialize only gcc links, it might be a
    # good idea to serialize all links.
    engine.set_target_variable(targets, 'JAM_SEMAPHORE', '<s>gcc-link-semaphore')
예제 #38
0
    def process(self, target, matches, binding):
        included_angle = regex.transform(matches, self.re_include_angle)
        included_quoted = regex.transform(matches, self.re_include_quoted)
        imported = regex.transform(matches, self.re_import, [1, 3])
        imported_tlbs = regex.transform(matches, self.re_importlib, [1, 3])

        # CONSIDER: the new scoping rule seem to defeat "on target" variables.
        g = bjam.call('get-target-variable', target, 'HDRGRIST')[0]
        b = os.path.normpath(os.path.dirname(binding))

        # Attach binding of including file to included targets.
        # When target is directly created from virtual target
        # this extra information is unnecessary. But in other
        # cases, it allows to distinguish between two headers of the
        # same name included from different places.
        g2 = g + "#" + b

        g = "<" + g + ">"
        g2 = "<" + g2 + ">"

        included_angle = [g + x for x in included_angle]
        included_quoted = [g + x for x in included_quoted]
        imported = [g + x for x in imported]
        imported_tlbs = [g + x for x in imported_tlbs]

        all = included_angle + included_quoted + imported

        bjam.call('INCLUDES', [target], all)
        bjam.call('DEPENDS', [target], imported_tlbs)
        bjam.call('NOCARE', all + imported_tlbs)
        engine.set_target_variable(
            included_angle, 'SEARCH',
            [utility.get_value(inc) for inc in self.includes])
        engine.set_target_variable(
            included_quoted, 'SEARCH',
            [utility.get_value(inc) for inc in self.includes])
        engine.set_target_variable(
            imported, 'SEARCH',
            [utility.get_value(inc) for inc in self.includes])
        engine.set_target_variable(
            imported_tlbs, 'SEARCH',
            [utility.get_value(inc) for inc in self.includes])

        get_manager().scanners().propagate(
            type.get_scanner('CPP', PropertySet(self.includes)),
            included_angle + included_quoted)
        get_manager().scanners().propagate(self, imported)
예제 #39
0
def __construct_really(project, name, target_type, prop_set, sources):
    """ Attempts to construct target by finding viable generators, running them
        and selecting the dependency graph.
    """
    if __debug__:
        from .targets import ProjectTarget
        assert isinstance(project, ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert isinstance(target_type, basestring)
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)
    viable_generators = find_viable_generators(target_type, prop_set)

    result = []

    dout("      *** %d viable generators" % len(viable_generators))

    generators_that_succeeded = []

    for g in viable_generators:
        __active_generators.append(g)
        r = try_one_generator(project, name, g, target_type, prop_set, sources)
        del __active_generators[-1]

        if r:
            generators_that_succeeded.append(g)
            if result:
                output = cStringIO.StringIO()
                print >> output, "ambiguity found when searching for best transformation"
                print >> output, "Trying to produce type '%s' from: " % (
                    target_type)
                for s in sources:
                    print >> output, " - " + s.str()
                print >> output, "Generators that succeeded:"
                for g in generators_that_succeeded:
                    print >> output, " - " + g.id()
                print >> output, "First generator produced: "
                for t in result[1:]:
                    print >> output, " - " + str(t)
                print >> output, "Second generator produced:"
                for t in r[1:]:
                    print >> output, " - " + str(t)
                get_manager().errors()(output.getvalue())
            else:
                result = r

    return result
예제 #40
0
def alias(name,
          sources=[],
          requirements=[],
          default_build=[],
          usage_requirements=[]):

    project = get_manager().projects().current()
    targets = get_manager().targets()

    targets.main_target_alternative(
        AliasTarget(
            name, project,
            targets.main_target_sources(sources, name, no_renaming=True),
            targets.main_target_requirements(requirements or [], project),
            targets.main_target_default_build(default_build, project),
            targets.main_target_usage_requirements(usage_requirements or [],
                                                   project)))
예제 #41
0
파일: message.py 프로젝트: wzssyqa/build
def message(name, *args):

    if type(name) == type([]):
        name = name[0]

    t = get_manager().targets()
    project = get_manager().projects().current()

    return t.main_target_alternative(
        MessageTargetClass(
            name, project,
            t.main_target_sources([], name),
            t.main_target_requirements([], project),
            t.main_target_default_build([], project),
            t.main_target_usage_requirements([], project),
            *args
        ))
예제 #42
0
def declare_top_level_targets(libraries, headers):

    declare_install_and_stage_proper_targets(libraries, headers)

    targets.create_metatarget(TopLevelTarget, "install",
                              ["install-proper", "install-unversioned"])
    targets.create_metatarget(TopLevelTarget, "stage",
                              ["stage-proper", "stage-unversioned"])

    message("explain", "\nBuilding the Boost C++ Libraries.\n\n")

    get_manager().projects().current().mark_targets_as_explicit(
        ["install", "stage", "explain"])

    # This target is built by default, and will forward to 'stage'
    # after producing some explanations.
    targets.create_metatarget(TopLevelTarget, "forward", ["explain", "stage"])
예제 #43
0
    def register_actual_name(self, actual_name, virtual_target):
        assert isinstance(actual_name, basestring)
        assert isinstance(virtual_target, VirtualTarget)
        if actual_name in self.actual_:
            cs1 = self.actual_[actual_name].creating_subvariant()
            cs2 = virtual_target.creating_subvariant()
            cmt1 = cs1.main_target()
            cmt2 = cs2.main_target()

            action1 = self.actual_[actual_name].action()
            action2 = virtual_target.action()

            properties_added = []
            properties_removed = []
            if action1 and action2:
                p1 = action1.properties()
                p1 = p1.raw()
                p2 = action2.properties()
                p2 = p2.raw()

                properties_removed = set.difference(p1, p2)
                if not properties_removed:
                    properties_removed = ["none"]

                properties_added = set.difference(p2, p1)
                if not properties_added:
                    properties_added = ["none"]

            # FIXME: Revive printing of real location.
            get_manager().errors()("Duplicate name of actual target: '%s'\n"
                                   "previous virtual target '%s'\n"
                                   "created from '%s'\n"
                                   "another virtual target '%s'\n"
                                   "created from '%s'\n"
                                   "added properties:\n%s\n"
                                   "removed properties:\n%s\n" %
                                   (actual_name, self.actual_[actual_name],
                                    cmt1.project().location(), virtual_target,
                                    cmt2.project().location(), '\n'.join(
                                        '\t' + p
                                        for p in properties_added), '\n'.join(
                                            '\t' + p
                                            for p in properties_removed)))

        else:
            self.actual_[actual_name] = virtual_target
예제 #44
0
def install_data(target_name, package_name, data, requirements):
    if not package_name:
        package_name = target_name

    if option.get("prefix"):
        # If --prefix is explicitly specified on the command line,
        # then we need wipe away any settings of datarootdir
        option.set("datarootdir", None)

    prefix = get_prefix(package_name, requirements)
    datadir = option.get("datarootdir", os.path.join(prefix, "share"))

    stage.install(
        target_name, data,
        requirements + ["<location>" + os.path.join(datadir, package_name)])

    get_manager().projects().current().mark_targets_as_explicit([target_name])
예제 #45
0
파일: type.py 프로젝트: malinost/boost
def register (type, suffixes = [], base_type = None):
    """ Registers a target type, possibly derived from a 'base-type'. 
        If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
        Also, the first element gives the suffix to be used when constructing and object of
        'type'.
        type: a string
        suffixes: None or a sequence of strings
        base_type: None or a string
    """
    # Type names cannot contain hyphens, because when used as
    # feature-values they will be interpreted as composite features
    # which need to be decomposed.
    if __re_hyphen.search (type):
        raise BaseException ('type name "%s" contains a hyphen' % type)
    
    if __types.has_key (type):
        raise BaseException ('Type "%s" is already registered.' % type)

    entry = {}
    entry ['base'] = base_type
    entry ['derived'] = []
    entry ['scanner'] = None
    __types [type] = entry
    
    if base_type:
        __types [base_type]['derived'].append (type)

    if len (suffixes) > 0:
        # Generated targets of 'type' will use the first of 'suffixes'
        # (this may be overriden)            
        set_generated_target_suffix (type, [], suffixes [0])
        
        # Specify mapping from suffixes to type
        register_suffixes (suffixes, type)
    
    feature.extend('target-type', [type])
    feature.extend('main-target-type', [type])
    feature.extend('base-target-type', [type])

    if base_type:
        feature.compose ('<target-type>' + type, replace_grist (base_type, '<base-target-type>'))
        feature.compose ('<base-target-type>' + type, '<base-target-type>' + base_type)

    # FIXME: resolving recursive dependency.
    from b2.manager import get_manager
    get_manager().projects().project_rules().add_rule_for_type(type)
예제 #46
0
def translate_indirect(properties, context_module):
    """Assumes that all feature values that start with '@' are
    names of rules, used in 'context-module'. Such rules can be
    either local to the module or global. Qualified local rules
    with the name of the module."""
    assert is_iterable_typed(properties, Property)
    assert isinstance(context_module, basestring)
    result = []
    for p in properties:
        if p.value()[0] == '@':
            q = qualify_jam_action(p.value()[1:], context_module)
            get_manager().engine().register_bjam_action(q)
            result.append(Property(p.feature(), '@' + q, p.condition()))
        else:
            result.append(p)

    return result
예제 #47
0
파일: alias.py 프로젝트: malinost/boost
def alias(name,
          sources,
          requirements=None,
          default_build=None,
          usage_requirements=None):
    project = get_manager().projects().current()
    targets = get_manager().targets()

    if default_build:
        default_build = default_build[0]

    targets.main_target_alternative(
        AliasTarget(
            name[0], project, targets.main_target_sources(sources, name),
            targets.main_target_requirements(requirements or [], project),
            targets.main_target_default_build(default_build, project),
            targets.main_target_usage_requirements(usage_requirements or [],
                                                   project)))
예제 #48
0
    def construct(self, name, source_targets, ps):
        assert isinstance(name, basestring)
        assert is_iterable_typed(source_targets, virtual_target.VirtualTarget)
        assert isinstance(ps, property_set.PropertySet)

        result = []
        for s in source_targets:
            if not isinstance(s, virtual_target.FileTarget):
                get_manager().errors()("Source to the 'cast' metatager is not a file")

            if s.action():
                get_manager().errors()("Only non-derived targets allowed as sources for 'cast'.")


            r = s.clone_with_different_type(self.type())
            result.append(get_manager().virtual_targets().register(r))

        return property_set.empty(), result
예제 #49
0
파일: stage.py 프로젝트: gleyba/yazik
    def run(self, project, name, ps, source):

        source = source[0]
        if ps.get('os') in ['NT', 'CYGWIN'] or ps.get('target-os') in ['windows', 'cygwin']:
            copied = copy_file(project, None, source, ps)
            return [get_manager().virtual_targets().register(copied)]
        else:
            a = source.action()
            if not a:
                # Non-derived file, just copy.
                copied = copy_file(project, None, source, ps)
            else:

                need_relink = ps.get('dll-path') != source.action().properties().get('dll-path')

                if need_relink:
                    # Rpath changed, need to relink.
                    copied = relink_file(project, source, ps)
                else:
                    copied = copy_file(project, None, source, ps)

            result = [get_manager().virtual_targets().register(copied)]
            # If the name is in the form NNN.XXX.YYY.ZZZ, where all 'X', 'Y' and
            # 'Z' are numbers, we need to create NNN.XXX and NNN.XXX.YYY
            # symbolic links.
            m = re.match("(.*)\\.([0123456789]+)\\.([0123456789]+)\\.([0123456789]+)$",
                         copied.name());
            if m:
                # Symlink without version at all is used to make
                # -lsome_library work.
                result.append(symlink(m.group(1), project, copied, ps))

                # Symlinks of some libfoo.N and libfoo.N.M are used so that
                # library can found at runtime, if libfoo.N.M.X has soname of
                # libfoo.N. That happens when the library makes some binary
                # compatibility guarantees. If not, it is possible to skip those
                # symlinks.
                if ps.get('install-no-version-symlinks') != ['on']:

                    result.append(symlink(m.group(1) + '.' + m.group(2), project, copied, ps))
                    result.append(symlink(m.group(1) + '.' + m.group(2) + '.' + m.group(3),
                                          project, copied, ps))

            return result
예제 #50
0
    def construct(self, name, source_targets, property_set):

        action_name = property_set.get("<action>")[0]

        action = Action(get_manager(), source_targets, action_name, property_set)
        # FIXME: type.type uses global data.
        target = FileTarget(self.name(), 1, type.type(self.name()),
                            self.project(), action)    
        return [ b2.build.property_set.empty(),
                 [self.project().manager().virtual_targets().register(target)]]
예제 #51
0
파일: gcc.py 프로젝트: sswamyn/HyperNEAT
def gcc_compile_c(targets, sources, properties):
    engine = get_manager().engine()
    # If we use the name g++ then default file suffix -> language mapping does
    # not work. So have to pass -x option. Maybe, we can work around this by
    # allowing the user to specify both C and C++ compiler names.
    #if $(>:S) != .c
    #{
    engine.set_target_variable (targets, 'LANG', '-x c')
    #}
    engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE'))
예제 #52
0
def should_clean_project(project):
    if project in project_targets:
        return True
    else:

        parent = get_manager().projects().attribute(project, "parent-module")
        if parent and parent != "user-config":
            return should_clean_project(parent)
        else:
            return False
예제 #53
0
    def register_actual_name(self, actual_name, virtual_target):
        if self.actual_.has_key(actual_name):
            cs1 = self.actual_[actual_name].creating_subvariant()
            cs2 = virtual_target.creating_subvariant()
            cmt1 = cs1.main_target()
            cmt2 = cs2.main_target()

            action1 = self.actual_[actual_name].action()
            action2 = virtual_target.action()

            properties_added = []
            properties_removed = []
            if action1 and action2:
                p1 = action1.properties()
                p1 = p1.raw()
                p2 = action2.properties()
                p2 = p2.raw()

                properties_removed = set.difference(p1, p2)
                if not properties_removed: properties_removed = "none"

                properties_added = set.difference(p2, p1)
                if not properties_added: properties_added = "none"

            # FIXME: Revive printing of real location.
            get_manager().errors()(
                "Duplicate name of actual target: '%s'\n"
                "previous virtual target '%s'\n"
                "created from '%s'\n"
                "another virtual target '%s'\n"
                "created from '%s'\n"
                "added properties: '%s'\n"
                "removed properties: '%s'\n" % (
                    actual_name,
                    self.actual_[actual_name],
                    "loc",  #cmt1.location (),
                    virtual_target,
                    "loc",  #cmt2.location (),
                    properties_added,
                    properties_removed))

        else:
            self.actual_[actual_name] = virtual_target
def tag_std(name, type, prop_set):
    name = 'boost_' + name
    if 'static' in prop_set.get('<link>') and 'windows' in prop_set.get('<target-os>'):
        name = 'lib' + name
    result = None

    if __layout == 'system':
        versionRe = re.search('^([0-9]+)_([0-9]+)', __version_tag)
        if versionRe and versionRe.group(1) == '1' and int(versionRe.group(2)) < 39:
            result = tag_tagged(name, type, prop_set)
        else:
            result = tag_system(name, type, prop_set)
    elif __layout == 'tagged':
        result = tag_tagged(name, type, prop_set)
    elif __layout == 'versioned':
        result = tag_versioned(name, type, prop_set)
    else:
        get_manager().errors()("Missing layout")
    return result
def init(version, options = None):
    assert(isinstance(version,list))
    assert(len(version)==1)
    version = version[0]
    if version in __boost_configured:
        get_manager().errors()("Boost {} already configured.".format(version));
    else:
        global __boost_default
        if debug():
            if not __boost_default:
                print "notice: configuring default boost library {}".format(version)
            print "notice: configuring boost library {}".format(version)

        if not __boost_default:
            __boost_default = version
        properties = []
        for option in options:
            properties.append(property.create_from_string(option))
        __boost_configured[ version ] = property_set.PropertySet(properties)
예제 #56
0
    def generate(self, ps):
        global top_level_targets
        top_level_targets.append(self.name())

        if build_type == "minimal":

            os = ps.get('target-os')
            # Because we completely override parent's 'generate'
            # we need to check for default value of feature ourself.
            if not os:
                os = feature.get('target-os').default()

            if os == "windows":
                expanded = targets.apply_default_build(
                    ps, self.minimal_properties_win)
            else:
                expanded = targets.apply_default_build(ps,
                                                       self.minimal_properties)
            return self.build_multiple(expanded)

        elif build_type == "complete":

            expanded = targets.apply_default_build(ps,
                                                   self.complete_properties)

            # Filter inappopriate combinations
            filtered = []
            for p in expanded:

                # See comment in handle-static-runtime regarding this logic.
                if ps.get("link") == ["shared"] and p.get("runtime-link") == ["static"] \
                   and p.get("toolset") != ["cw"]:
                    # Skip this
                    pass
                else:
                    filtered.append(p)

            return build_multiple(filtered)

        else:

            get_manager().errors("Unknown build type")
예제 #57
0
def __construct_really(project, name, target_type, prop_set, sources):
    """ Attempts to construct target by finding viable generators, running them
        and selecting the dependency graph.
    """
    viable_generators = find_viable_generators(target_type, prop_set)

    result = []

    project.manager().logger().log(
        __name__, "*** %d viable generators" % len(viable_generators))

    generators_that_succeeded = []

    for g in viable_generators:
        __active_generators.append(g)
        r = try_one_generator(project, name, g, target_type, prop_set, sources)
        del __active_generators[-1]

        if r:
            generators_that_succeeded.append(g)
            if result:
                output = cStringIO.StringIO()
                print >> output, "ambiguity found when searching for best transformation"
                print >> output, "Trying to produce type '%s' from: " % (
                    target_type)
                for s in sources:
                    print >> output, " - " + s.str()
                print >> output, "Generators that succeeded:"
                for g in generators_that_succeeded:
                    print >> output, " - " + g.id()
                print >> output, "First generator produced: "
                for t in result[1:]:
                    print >> output, " - " + str(t)
                print >> output, "Second generator produced:"
                for t in r[1:]:
                    print >> output, " - " + str(t)
                get_manager().errors()(output.getvalue())
            else:
                result = r

    return result
예제 #58
0
파일: alias.py 프로젝트: gleyba/yazik
def alias(name,
          sources=[],
          requirements=[],
          default_build=[],
          usage_requirements=[]):
    assert isinstance(name, basestring)
    assert is_iterable_typed(sources, basestring)
    assert is_iterable_typed(requirements, basestring)
    assert is_iterable_typed(default_build, basestring)
    assert is_iterable_typed(usage_requirements, basestring)
    project = get_manager().projects().current()
    targets = get_manager().targets()

    targets.main_target_alternative(
        AliasTarget(
            name, project,
            targets.main_target_sources(sources, name, no_renaming=True),
            targets.main_target_requirements(requirements or [], project),
            targets.main_target_default_build(default_build, project),
            targets.main_target_usage_requirements(usage_requirements or [],
                                                   project)))
예제 #59
0
def libraries_to_install(existing_libraries):
    # Decides which libraries are to be installed by looking at --with-<library>
    # --without-<library> arguments. Returns the list of directories under "libs"
    # which must be built and installed.

    with_parameter = regex.transform(sys.argv, "--with-(.*)")
    without_parameter = regex.transform(sys.argv, "--without-(.*)")

    if not with_parameter and not without_parameter:
        # Nothing is specified on command line. See if maybe
        # project-config.jam has some choices.
        project_config_libs = bjam.call("peek", "project-config", "libraries")
        with_parameter = regex.transform(project_config_libs, "--with-(.*)")
        without_parameter = regex.transform(project_config_libs,
                                            "--without-(.*)")

    # Do some checks.
    if with_parameter and without_parameter:
        get_manager().errors()(
            "both --with-<library> and --without-<library> specified")

    wrong = set.difference(with_parameter, existing_libraries)
    if wrong:
        get_manager().errors()("wrong library name '" + wrong[0] +
                               "' in the --with-<library> option.")

    wrong = set.difference(without_parameter, existing_libraries)
    if wrong:
        get_manager().errors()("wrong library name '" + wrong[0] +
                               "' in the --without-<library> option.")

    if with_parameter:
        return set.intersection(existing_libraries, with_parameter)
    else:
        return set.difference(existing_libraries, without_parameter)
예제 #60
0
def create_from_string(s, allow_condition=False):

    condition = []
    import types
    if not isinstance(s, types.StringType):
        print type(s)
    if __re_has_condition.search(s):

        if not allow_condition:
            raise BaseException(
                "Conditional property is not allowed in this context")

        m = __re_separate_condition_and_property.match(s)
        condition = m.group(1)
        s = m.group(2)

    # FIXME: break dependency cycle
    from b2.manager import get_manager

    feature_name = get_grist(s)
    if not feature_name:
        if feature.is_implicit_value(s):
            f = feature.implied_feature(s)
            value = s
        else:
            raise get_manager().errors()(
                "Invalid property '%s' -- unknown feature" % s)
    else:
        f = feature.get(feature_name)

        value = get_value(s)
        if not value:
            get_manager().errors()(
                "Invalid property '%s' -- no value specified" % s)

    if condition:
        condition = [create_from_string(x) for x in condition.split(',')]

    return Property(f, value, condition)