コード例 #1
0
                             (env_name, new_src_dir, new_src_dir))
            self.java_jar_cmd_list.append(new_src_dir)

        pack_list = []
        classes_var_list = []
        if self.java_jar_dep_source_list:
            self._java_jar_rules_prepare_dep(new_src_dir)

        self._java_jar_rules_compile_src(target_source_list, new_src_dir,
                                         pack_list, classes_var_list)

        self._java_jar_rules_make_jar(pack_list, classes_var_list)


def java_jar(name,
             srcs=[],
             deps=[],
             prebuilt=False,
             pre_build=False,
             **kwargs):
    """Define java_jar target. """
    target = JavaJarTarget(name, srcs, deps, prebuilt or pre_build,
                           build_manager.instance, kwargs)
    if pre_build:
        console.warning('//%s:%s: "pre_build" has been deprecated, '
                        'please use "prebuilt"' % (target.path, target.name))
    build_manager.instance.register_target(target)


build_rules.register_function(java_jar)
コード例 #2
0
              exclusions=[],
              testdata=[],
              target_under_test='',
              **kwargs):
    """Define java_test target. """
    target = JavaTest(name, srcs, deps, resources, source_encoding, warnings,
                      main_class, exclusions, testdata, target_under_test,
                      kwargs)
    build_manager.instance.register_target(target)


def java_fat_library(name,
                     srcs=[],
                     deps=[],
                     resources=[],
                     source_encoding=None,
                     warnings=None,
                     exclusions=[],
                     **kwargs):
    """Define java_fat_library target. """
    target = JavaFatLibrary(name, srcs, deps, resources, source_encoding,
                            warnings, exclusions, kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(maven_jar)
build_rules.register_function(java_binary)
build_rules.register_function(java_library)
build_rules.register_function(java_test)
build_rules.register_function(java_fat_library)
コード例 #3
0
    def _thrift_gen_cpp2_files(self, src):
        """Get the c++ files generated from thrift file."""
        return [self._target_file_path(f)
                for f in self.fbthrift_helpers[src].get_generated_cpp2_files()]

    def generate(self):
        self.error('FIXME: fbthrift is still not supported by the ninja backend.')
        # (don't forget `generated_hdrs`)


def fbthrift_library(name=None,
                     srcs=[],
                     deps=[],
                     optimize=None,
                     visibility=None,
                     deprecated=False,
                     **kwargs):
    """fbthrift_library target."""
    fbthrift_library_target = FBThriftLibrary(
            name=name,
            srcs=srcs,
            deps=deps,
            optimize=optimize,
            visibility=visibility,
            deprecated=deprecated,
            kwargs=kwargs)
    build_manager.instance.register_target(fbthrift_library_target)


build_rules.register_function(fbthrift_library)
コード例 #4
0
def scala_test(name=None,
               srcs=None,
               deps=[],
               resources=[],
               visibility=None,
               source_encoding=None,
               warnings=None,
               exclusions=[],
               testdata=[],
               **kwargs):
    """Build a scala test target
    Args:
        Most attributes are similar to java_test.
    """
    target = ScalaTest(name=name,
                       srcs=srcs,
                       deps=deps,
                       resources=resources,
                       visibility=visibility,
                       source_encoding=source_encoding,
                       warnings=warnings,
                       exclusions=exclusions,
                       testdata=testdata,
                       kwargs=kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(scala_library)
build_rules.register_function(scala_fat_library)
build_rules.register_function(scala_test)
コード例 #5
0
# Each include in a BUILD file can only affect itself
__current_globles = None


# Include a defination file in a BUILD file
def include(name):
    from blade import build_manager
    if name.startswith('//'):
        dir = build_manager.instance.get_root_dir()
        name = name[2:]
    else:
        dir = build_manager.instance.get_current_source_path()
    exec_(os.path.join(dir, name), __current_globles, None)


build_rules.register_function(enable_if)
build_rules.register_function(glob)
build_rules.register_function(include)


def _load_build_file(source_dir, processed_source_dirs, blade):
    """Load the BUILD and place the targets into database.

    Invoked by _load_targets.  Load and execute the BUILD
    file, which is a Python script, in source_dir.  Statements in BUILD
    depends on global variable current_source_dir, and will register build
    target/rules into global variables target_database.  Report error
    and exit if path/BUILD does NOT exist.
    The parameters processed_source_dirs refers to a set defined in the
    caller and used to avoid duplicated execution of BUILD files.
コード例 #6
0
    def ninja_rules(self):
        self.error('Not implemented')


def swig_library(name,
                 srcs=[],
                 deps=[],
                 visibility=None,
                 warning='',
                 java_package='',
                 java_lib_packed=False,
                 optimize=[],
                 extra_swigflags=[],
                 **kwargs):
    """swig_library target. """
    target = SwigLibrary(name=name,
                         srcs=srcs,
                         deps=deps,
                         visibility=visibility,
                         warning=warning,
                         java_package=java_package,
                         java_lib_packed=java_lib_packed,
                         optimize=optimize,
                         extra_swigflags=extra_swigflags,
                         kwargs=kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(swig_library)
コード例 #7
0
            cpp_sources.append(names[1])
        self._cc_objects_ninja(cpp_sources, True, generated_headers=cpp_headers)
        self._cc_library_ninja()
        self.ninja_proto_rules(self.blade.get_options(), plugin_flags)


def proto_library(name,
                  srcs=[],
                  deps=[],
                  optimize=[],
                  deprecated=False,
                  generate_descriptors=False,
                  plugins=[],
                  source_encoding='iso-8859-1',
                  **kwargs):
    """proto_library target. """
    proto_library_target = ProtoLibrary(name,
                                        srcs,
                                        deps,
                                        optimize,
                                        deprecated,
                                        generate_descriptors,
                                        plugins,
                                        source_encoding,
                                        build_manager.instance,
                                        kwargs)
    build_manager.instance.register_target(proto_library_target)


build_rules.register_function(proto_library)
コード例 #8
0
        srcs = [self._source_file_path(s) for s in self.srcs]
        output = self._target_file_path()
        self.ninja_build(output, 'shelltest', inputs=srcs)
        targets = self.blade.get_build_targets()
        inputs, testdata = [], []
        for key, type, dst in self.data['locations']:
            path = targets[key]._get_target_file(type)
            if not path:
                console.warning('%s: Location %s %s is missing. Ignored.' %
                                (self.fullname, key, type))
            else:
                inputs.append(path)
                if not dst:
                    testdata.append(os.path.basename(path))
                else:
                    testdata.append(dst)
        if inputs:
            output = '%s.testdata' % self._target_file_path()
            self.ninja_build(output,
                             'shelltestdata',
                             inputs=inputs,
                             variables={'testdata': ' '.join(testdata)})


def sh_test(name, srcs, deps=[], testdata=[], **kwargs):
    build_manager.instance.register_target(
        ShellTest(name, srcs, deps, testdata, kwargs))


build_rules.register_function(sh_test)
コード例 #9
0
                console.error_exit('failed to build //%s:%s, please install php modules' % (
                           self.path, self.name))
            else:
                self._swig_library_rules_php(dep_files_map)


def swig_library(name,
                 srcs=[],
                 deps=[],
                 warning='',
                 java_package='',
                 java_lib_packed=False,
                 optimize=[],
                 extra_swigflags=[],
                 **kwargs):
    """swig_library target. """
    target = SwigLibrary(name,
                         srcs,
                         deps,
                         warning,
                         java_package,
                         java_lib_packed,
                         optimize,
                         extra_swigflags,
                         build_manager.instance,
                         kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(swig_library)
コード例 #10
0
        self._cc_objects_ninja([lex_cc, yacc_cc], True)
        self._cc_library_ninja()


def lex_yacc_library(name,
                     srcs=[],
                     deps=[],
                     warning='yes',
                     defs=[],
                     incs=[],
                     allow_undefined=False,
                     recursive=False,
                     prefix=None,
                     **kwargs):
    """lex_yacc_library. """
    target = LexYaccLibrary(name,
                            srcs,
                            deps,
                            warning,
                            defs,
                            incs,
                            allow_undefined,
                            recursive,
                            prefix,
                            build_manager.instance,
                            kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(lex_yacc_library)
コード例 #11
0
        vars = {
            'entries' : ' '.join(entries),
            'packageroot' : packageroot,
        }
        type = self.data['type']
        rule = self.ninja_rule_from_package_type(type)
        if type != 'zip':
            vars['tarflags'] = self.tar_flags(type)
        self.ninja_build(output, rule, inputs=package_sources, variables=vars)


def package(name,
            srcs,
            deps=[],
            type='tar',
            out=None,
            shell=False,
            **kwargs):
    package_target = PackageTarget(name,
                                   srcs,
                                   deps,
                                   type,
                                   out,
                                   shell,
                                   build_manager.instance,
                                   kwargs)
    build_manager.instance.register_target(package_target)


build_rules.register_function(package)
コード例 #12
0
# Each include in a BUILD file can only affect itself
__current_globles = None


# Include a defination file in a BUILD file
def include(name):
    from blade import build_manager
    if name.startswith('//'):
        dir = build_manager.instance.get_root_dir()
        name = name[2:]
    else:
        dir = build_manager.instance.get_current_source_path()
    execfile(os.path.join(dir, name), __current_globles, None)


build_rules.register_function(enable_if)
build_rules.register_function(glob)
build_rules.register_function(include)


def _load_build_file(source_dir, processed_source_dirs, blade):
    """Load the BUILD and place the targets into database.

    Invoked by _load_targets.  Load and execute the BUILD
    file, which is a Python script, in source_dir.  Statements in BUILD
    depends on global variable current_source_dir, and will register build
    target/rules into global variables target_database.  Report error
    and exit if path/BUILD does NOT exist.
    The parameters processed_source_dirs refers to a set defined in the
    caller and used to avoid duplicated execution of BUILD files.
コード例 #13
0
        for key, type, dst in self.data['locations']:
            path = targets[key]._get_target_file(type)
            if not path:
                console.warning('%s: Location %s %s is missing. Ignored.' %
                                (self.fullname, key, type))
            else:
                inputs.append(path)
                if not dst:
                    testdata.append(os.path.basename(path))
                else:
                    testdata.append(dst)
        if inputs:
            output = '%s.testdata' % self._target_file_path()
            self.ninja_build(output, 'shelltestdata', inputs=inputs,
                             variables={'testdata' : ' '.join(testdata)})


def sh_test(name,
            srcs,
            deps=[],
            testdata=[],
            **kwargs):
    build_manager.instance.register_target(ShellTest(name,
                                          srcs,
                                          deps,
                                          testdata,
                                          kwargs))


build_rules.register_function(sh_test)
コード例 #14
0
                                       deps=deps,
                                       visibility=visibility,
                                       base=base,
                                       kwargs=kwargs)
    else:
        target = PythonLibrary(name=name,
                               srcs=srcs,
                               deps=deps,
                               visibility=visibility,
                               base=base,
                               kwargs=kwargs)

    build_manager.instance.register_target(target)


build_rules.register_function(py_library)


class PythonBinary(PythonLibrary):
    """A python binary target subclass.
    This class generates python binary package.
    """
    def __init__(self, name, srcs, deps, visibility, main, base, kwargs):
        """Init method. """
        srcs = var_to_list(srcs)
        deps = var_to_list(deps)

        super(PythonBinary, self).__init__(name=name,
                                           srcs=srcs,
                                           deps=deps,
                                           visibility=visibility,
コード例 #15
0
                         })
        self.data['generated_hdrs'].append(index[0])
        sources = ['%s.c' % self.name]
        for resource in self.srcs:
            generated_source = '%s.c' % resource
            self.ninja_build(self._target_file_path(generated_source), 'resource',
                             inputs=self._source_file_path(resource))
            sources.append(generated_source)
        self._cc_objects_ninja(sources, True)
        self._cc_library_ninja()


def resource_library(name,
                     srcs=[],
                     deps=[],
                     optimize=[],
                     extra_cppflags=[],
                     **kwargs):
    """scons_resource_library. """
    target = ResourceLibrary(name,
                             srcs,
                             deps,
                             optimize,
                             extra_cppflags,
                             build_manager.instance,
                             kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(resource_library)
コード例 #16
0
ファイル: go_targets.py プロジェクト: neighbWang/blade-build
        for src in srcs:
            package = extract_go_package(os.path.join(path, src))
            if package == 'main':
                main = True
                break
        if main:
            go_binary(name=name,
                      srcs=srcs,
                      deps=deps,
                      visibility=visibility,
                      extra_goflags=extra_goflags)
        else:
            go_library(name=name,
                       srcs=srcs,
                       deps=deps,
                       visibility=visibility,
                       extra_goflags=extra_goflags)
    if tests:
        go_test(name='%s_test' % name,
                srcs=tests,
                deps=deps,
                visibility=visibility,
                testdata=testdata,
                extra_goflags=extra_goflags)


build_rules.register_function(go_library)
build_rules.register_function(go_binary)
build_rules.register_function(go_test)
build_rules.register_function(go_package)
コード例 #17
0
                      target_under_test,
                      kwargs)
    build_manager.instance.register_target(target)


def java_fat_library(name,
                     srcs=[],
                     deps=[],
                     resources=[],
                     source_encoding=None,
                     warnings=None,
                     exclusions=[],
                     **kwargs):
    """Define java_fat_library target. """
    target = JavaFatLibrary(name,
                            srcs,
                            deps,
                            resources,
                            source_encoding,
                            warnings,
                            exclusions,
                            kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(maven_jar)
build_rules.register_function(java_binary)
build_rules.register_function(java_library)
build_rules.register_function(java_test)
build_rules.register_function(java_fat_library)
コード例 #18
0
                             'path': self.path
                         })
        sources = ['%s.c' % self.name]
        for resource in self.srcs:
            generated_source = '%s.c' % resource
            self.ninja_build('resource', self._target_file_path(generated_source),
                             inputs=self._source_file_path(resource))
            sources.append(generated_source)
        self._cc_objects_ninja(sources, True)
        self._cc_library_ninja()


def resource_library(name,
                     srcs=[],
                     deps=[],
                     optimize=[],
                     extra_cppflags=[],
                     **kwargs):
    """resource_library. """
    target = ResourceLibrary(
            name,
            srcs=srcs,
            deps=deps,
            optimize=optimize,
            extra_cppflags=extra_cppflags,
            kwargs=kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(resource_library)
コード例 #19
0
                             source_encoding,
                             warnings,
                             exclusions,
                             kwargs)
    build_manager.instance.register_target(target)


def scala_test(name,
               srcs,
               deps=[],
               resources=[],
               source_encoding=None,
               warnings=None,
               testdata=[],
               **kwargs):
    """Define scala_test target. """
    target = ScalaTest(name,
                       srcs,
                       deps,
                       resources,
                       source_encoding,
                       warnings,
                       testdata,
                       kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(scala_library)
build_rules.register_function(scala_fat_library)
build_rules.register_function(scala_test)
コード例 #20
0
                  deps=[],
                  optimize=[],
                  deprecated=False,
                  generate_descriptors=False,
                  target_languages=None,
                  plugins=[],
                  source_encoding='iso-8859-1',
                  **kwargs):
    """proto_library target.
    Args:
        generate_descriptors (bool): Whether generate binary protobuf descriptors.
        target_languages (Sequence[str]): Code for target languages to be generated, such as
            `java`, `python`, see protoc's `--xx_out`s.
            NOTE: The `cpp` target code is always generated.
    """
    proto_library_target = ProtoLibrary(name,
                                        srcs,
                                        deps,
                                        optimize,
                                        deprecated,
                                        generate_descriptors,
                                        target_languages,
                                        plugins,
                                        source_encoding,
                                        build_manager.instance,
                                        kwargs)
    build_manager.instance.register_target(proto_library_target)


build_rules.register_function(proto_library)
コード例 #21
0
ファイル: py_targets.py プロジェクト: chen3feng/typhoon-blade
                                       deps,
                                       base,
                                       visibility,
                                       kwargs)
    else:
        target = PythonLibrary(name,
                               srcs,
                               deps,
                               base,
                               visibility,
                               kwargs)

    build_manager.instance.register_target(target)


build_rules.register_function(py_library)


class PythonBinary(PythonLibrary):
    """A python binary target subclass.

    This class is derived from SconsTarget and generates python binary package.

    """
    def __init__(self,
                 name,
                 srcs,
                 deps,
                 main,
                 base,
                 kwargs):
コード例 #22
0
        deps=[],
        visibility=None,
        warning='yes',
        defs=[],
        incs=[],
        allow_undefined=False,
        recursive=False,
        prefix=None,
        lexflags=[],
        yaccflags=[],
        **kwargs):
    """lex_yacc_library. """
    target = LexYaccLibrary(
            name=name,
            srcs=srcs,
            deps=deps,
            warning=warning,
            visibility=visibility,
            defs=defs,
            incs=incs,
            allow_undefined=allow_undefined,
            recursive=recursive,
            prefix=prefix,
            lexflags=lexflags,
            yaccflags=yaccflags,
            kwargs=kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(lex_yacc_library)
コード例 #23
0
        for src in self.srcs:
            thrift_files = self._thrift_gen_cpp_files(src)
            self.ninja_build(thrift_files, 'thrift',
                             inputs=self._source_file_path(src))
            headers += [h for h in thrift_files if h.endswith('.h')]
            thrift_cpp_sources = [s for s in thrift_files if s.endswith('.cpp')]
            sources += [os.path.relpath(s, build_path) for s in thrift_cpp_sources]
        self.data['generated_hdrs'] = headers
        self._cc_objects_ninja(sources, True, generated_headers=headers)
        self._cc_library_ninja()


def thrift_library(name,
                   srcs=[],
                   deps=[],
                   optimize=[],
                   deprecated=False,
                   **kwargs):
    """thrift_library target. """
    thrift_library_target = ThriftLibrary(name,
                                          srcs,
                                          deps,
                                          optimize,
                                          deprecated,
                                          build_manager.instance,
                                          kwargs)
    build_manager.instance.register_target(thrift_library_target)


build_rules.register_function(thrift_library)
コード例 #24
0
             **kwargs):
    """General Build Rule
    Args:
        generated_hdrs: Optional[bool],
            Specify whether this target will generate c/c++ header files.
            Defaultly, gen_rule will calculate a generated header files list automatically
            according to the names in the |outs|`
            But if they are not specified in the outs, and we sure know this target will generate
            some headers, we should set this argument to True.
        export_incs List(str), the include dirs to be exported to dependants, NOTE these dirs are
            under the target dir, it's different with cc_library.export_incs.
        heavy: bool, Whether this target is a heavy target, which means to build it will cost many
            cpu/memory.
    """
    gen_rule_target = GenRuleTarget(name=name,
                                    srcs=srcs,
                                    deps=deps,
                                    visibility=visibility,
                                    outs=outs,
                                    cmd=cmd,
                                    cmd_name=cmd_name,
                                    generated_hdrs=generated_hdrs,
                                    generated_incs=generated_incs,
                                    export_incs=export_incs,
                                    heavy=heavy,
                                    kwargs=kwargs)
    build_manager.instance.register_target(gen_rule_target)


build_rules.register_function(gen_rule)
コード例 #25
0
ファイル: package_target.py プロジェクト: acseed/blade-build
        type = self.attr['type']
        rule = self._rule_from_package_type(type)
        if type != 'zip':
            vars['tarflags'] = self.tar_flags(type)
        self.generate_build(rule,
                            output,
                            inputs=package_sources,
                            variables=vars)


def package(name=None,
            srcs=[],
            deps=[],
            visibility=None,
            type='tar',
            out=None,
            shell=False,
            **kwargs):
    package_target = PackageTarget(name=name,
                                   srcs=srcs,
                                   deps=deps,
                                   visibility=visibility,
                                   type=type,
                                   out=out,
                                   shell=shell,
                                   kwargs=kwargs)
    build_manager.instance.register_target(package_target)


build_rules.register_function(package)
コード例 #26
0
def cu_library(name,
               srcs=[],
               deps=[],
               warning='yes',
               defs=[],
               incs=[],
               extra_cppflags=[],
               extra_linkflags=[],
               **kwargs):
    target = CuLibrary(name, srcs, deps, warning, defs, incs, extra_cppflags,
                       extra_linkflags, build_manager.instance, kwargs)
    build_manager.instance.register_target(target)


build_rules.register_function(cu_library)


class CuBinary(CuTarget):
    """This class is derived from CuTarget and generates the cu_binary
    rules according to user options.

    """
    def __init__(self, name, srcs, deps, warning, defs, incs, extra_cppflags,
                 extra_linkflags, blade, kwargs):
        CuTarget.__init__(self, name, 'cu_binary', srcs, deps, warning, defs,
                          incs, extra_cppflags, extra_linkflags, blade, kwargs)

    def _cc_binary(self):
        env_name = self._env_name()
        var_name = self._var_name()
コード例 #27
0
        if '${_in_1}' in cmd:
            vars['_in_1'] = inputs[0]
        if '${_out_1}' in cmd:
            vars['_out_1'] = outputs[0]
        self.ninja_build(outputs, rule, inputs=inputs,
                         implicit_deps=self.implicit_dependencies(),
                         variables=vars)
        for i, out in enumerate(outputs):
            self._add_target_file(str(i), out)
        self.data['generated_hdrs'] = [o for o in outputs if o.endswith('.h')]


def gen_rule(name,
             srcs=[],
             deps=[],
             outs=[],
             cmd='',
             **kwargs):
    """scons_gen_rule. """
    gen_rule_target = GenRuleTarget(name,
                                    srcs,
                                    deps,
                                    outs,
                                    cmd,
                                    build_manager.instance,
                                    kwargs)
    build_manager.instance.register_target(gen_rule_target)


build_rules.register_function(gen_rule)