Пример #1
0
 def commands(self, toolset, target, input, output):
     # FIXME: use a parser instead of constructing the expression manually
     #        in here
     return [
         ListExpr([LiteralExpr("$(AR) rcu $@"), input]),
         ListExpr([LiteralExpr("$(RANLIB) $@")])
     ]
Пример #2
0
def test_list_expr_iterator():
    bool_yes = BoolValueExpr(True)
    bool_no = BoolValueExpr(False)
    empty_list = ListExpr([])
    a_list = ListExpr([bool_yes, bool_no])
    assert len(empty_list) == 0
    assert not empty_list
    assert len(a_list) == 2
    assert a_list
    assert list(a_list) == [bool_yes, bool_no]

    null = NullExpr()
    assert not null
    assert len(null) == 0
Пример #3
0
 def _linker_flags(self, toolset, target):
     cmd = self._arch_flags(toolset, target)
     libdirs = target.type.get_libdirs(target)
     if libdirs:
         cmd += bkl.expr.add_prefix("-L", ListExpr(libdirs))
     libs = target.type.get_libfiles(toolset, target)
     ldlibs = target.type.get_ldlibs(target)
     cmd += libs
     cmd += bkl.expr.add_prefix("-l", ListExpr(ldlibs)).items
     cmd += target.type.get_link_options(target)
     if toolset.extra_link_flags:
         cmd.append(LiteralExpr(toolset.extra_link_flags))
     if toolset.pthread_ld_flags and target["multithreading"]:
         cmd.append(LiteralExpr(toolset.pthread_ld_flags))
     return cmd
Пример #4
0
    def commands(self, toolset, target, input, output):
        needs_extra_deps_code = (isinstance(toolset, OSXGnuToolset)
                                 and _is_multiarch_target(target)
                                 )  # see GCC_DEPS_FLAGS
        cmd = [
            LiteralExpr("$(%s) -c -o $@ $(CPPFLAGS) $(%s)" %
                        (self._compiler, self._flags_var_name))
        ]
        if needs_extra_deps_code:
            cmd += [LiteralExpr("$(%s_deps_flags)" % self._compiler)]
        else:
            cmd += [LiteralExpr(toolset.deps_flags)]
        # FIXME: evaluating the flags here every time is inefficient
        cmd += self._arch_flags(toolset, target)
        if toolset.pic_flags and target["pic"]:
            cmd.append(LiteralExpr(toolset.pic_flags))
        if target["multithreading"]:
            cmd.append(LiteralExpr(toolset.pthread_cc_flags))
        cmd += bkl.expr.add_prefix("-D", target["defines"])
        cmd += bkl.expr.add_prefix("-I", target["includedirs"])

        warning_flags = toolset.warning_flags[str(target["warnings"])]
        if warning_flags is not None:
            cmd.append(LiteralExpr(warning_flags))

        cmd += target["compiler-options"]
        cmd += target[self._options_prop_name]
        # FIXME: use a parser instead of constructing the expression manually
        #        in here
        cmd.append(input)
        retval = [ListExpr(cmd)]

        if needs_extra_deps_code:
            # add command for generating the deps:
            cmd = [
                LiteralExpr(
                    "$(call %s_deps_cmd,$(%s),$(CPPFLAGS) $(%s)" %
                    (self._compiler, self._compiler, self._flags_var_name))
            ]
            cmd += bkl.expr.add_prefix("-D", target["defines"])
            cmd += bkl.expr.add_prefix("-I", target["includedirs"])
            cmd += target["compiler-options"]
            cmd += target[self._options_prop_name]
            cmd.append(input)
            cmd.append(LiteralExpr(")"))
            retval.append(ListExpr(cmd))

        return retval
Пример #5
0
    def _make_link_command(self,
                           toolset,
                           target,
                           input,
                           output_flags=None,
                           extra_flags=None):
        """
        Return the link command taking the specified inputs.

        The output_flags argument contains linker flags controlling the kind of
        output file to generate while extra_flags contain other options. This
        separation is relatively arbitrary and just makes the code using this
        function more convenient to write.
        """
        cmd = [LiteralExpr("$(CXX)")]
        if output_flags:
            cmd.append(LiteralExpr(output_flags))
        cmd.append(LiteralExpr("-o $@"))
        if extra_flags:
            cmd.append(LiteralExpr(extra_flags))
        cmd.append(LiteralExpr("$(LDFLAGS)"))
        cmd.append(input)
        # FIXME: use a parser instead of constructing the expression manually
        #        in here
        cmd += self._linker_flags(toolset, target)
        return [ListExpr(cmd)]
Пример #6
0
def test_expr_as_bool():
    bool_yes = BoolValueExpr(True)
    bool_no = BoolValueExpr(False)
    empty_list = ListExpr([])
    a_list = ListExpr([bool_yes, bool_no])
    literal = LiteralExpr("foo")
    empty_literal = LiteralExpr("")
    concat = ConcatExpr([empty_literal, literal, literal])
    empty_concat = ConcatExpr([empty_literal, empty_literal])

    assert bool(bool_yes)
    assert bool(a_list)
    assert bool(literal)
    assert bool(concat)
    assert not bool(bool_no)
    assert not bool(empty_list)
    assert not bool(empty_literal)
    assert not bool(empty_concat)
Пример #7
0
 def commands(self, toolset, target, input, output):
     cmd = [
         LiteralExpr("$(CXX) %s -o $@" % toolset.loadable_module_link_flag)
     ]
     cmd.append(LiteralExpr("$(LDFLAGS)"))
     cmd.append(input)
     # FIXME: use a parser instead of constructing the expression manually
     #        in here
     cmd += self._linker_flags(toolset, target)
     return [ListExpr(cmd)]
Пример #8
0
    def _make_link_command(self,
                           toolset,
                           target,
                           input,
                           output_flags=None,
                           extra_flags=None):
        """
        Return the link command taking the specified inputs.

        The output_flags argument contains linker flags controlling the kind of
        output file to generate while extra_flags contain other options. This
        separation is relatively arbitrary and just makes the code using this
        function more convenient to write.

        Notice that if output_flags is specified, we also automatically append
        the necessary linked flags to allow, or disallow, undefined symbols in
        output. This is again just a convenience, as this is only needed by those
        callers of this function that use output_flags.
        """
        cmd = [LiteralExpr("$(CXX)")]
        if output_flags:
            cmd.append(LiteralExpr(output_flags))

            if target["allow-undefined"]:
                undefined_link_flag = toolset.allow_undefined_link_flag
            else:
                undefined_link_flag = toolset.disallow_undefined_link_flag

            if undefined_link_flag:
                cmd.append(LiteralExpr(undefined_link_flag))

        cmd.append(LiteralExpr("-o $@"))
        if extra_flags:
            cmd.append(LiteralExpr(extra_flags))
        cmd.append(LiteralExpr("$(LDFLAGS)"))
        cmd.append(input)
        # FIXME: use a parser instead of constructing the expression manually
        #        in here
        cmd += self._linker_flags(toolset, target)
        return [ListExpr(cmd)]
Пример #9
0
 def commands(self, toolset, target, input, output):
     cmd = [LiteralExpr("$(CXX) -o $@ $(LDFLAGS)"), input]
     # FIXME: use a parser instead of constructing the expression manually
     #        in here
     cmd += self._linker_flags(toolset, target)
     return [ListExpr(cmd)]