def __init__(self,
                 name,
                 srcs,
                 deps,
                 optimize,
                 extra_cppflags,
                 kwargs):
        """Init method.

        Init the cc target.

        """
        super(ResourceLibrary, self).__init__(
                name=name,
                type='resource_library',
                srcs=srcs,
                deps=deps,
                visibility=None,
                warning='',
                defs=[],
                incs=[],
                export_incs=[],
                optimize=optimize,
                extra_cppflags=extra_cppflags,
                extra_linkflags=[],
                kwargs=kwargs)
        hdrs = [self._target_file_path('%s.h' % self.name)]
        self.data['generated_hdrs'] = hdrs
        cc_targets._declare_hdrs(self, hdrs)
Example #2
0
    def __init__(self,
                 name,
                 srcs,
                 deps,
                 visibility,
                 outs,
                 cmd,
                 cmd_name,
                 generated_hdrs,
                 generated_incs,
                 export_incs,
                 cleans,
                 heavy,
                 kwargs):
        """Init method.
        Init the gen rule target.
        """
        srcs = var_to_list(srcs)
        deps = var_to_list(deps)
        super(GenRuleTarget, self).__init__(
                name=name,
                type='gen_rule',
                srcs=srcs,
                deps=deps,
                visibility=visibility,
                kwargs=kwargs)

        if not outs:
            self.error('"outs" can not be empty')
        if not cmd:
            self.error('"cmd" can not be empty')
        outs = [os.path.normpath(o) for o in var_to_list(outs)]

        self.attr['outs'] = outs
        self.attr['locations'] = []
        self.attr['cmd'] = LOCATION_RE.sub(self._process_location_reference, cmd)
        self.attr['cmd_name'] = cmd_name
        self.attr['heavy'] = heavy
        self.cleans = var_to_list(cleans)
        for clean in self.cleans:
            self._remove_on_clean(self._target_file_path(clean))

        if generated_incs is not None:
            generated_incs = [self._target_file_path(inc) for inc in var_to_list(generated_incs)]
            self.attr['generated_incs'] = generated_incs
            for inc in generated_incs:
                cc_targets._declare_hdr_dir(self, inc)
        else:
            if generated_hdrs is None:
                # Auto judge
                generated_hdrs = [o for o in outs if cc_targets.is_header_file(o)]
            else:
                generated_hdrs = var_to_list(generated_hdrs)
            if generated_hdrs:
                generated_hdrs = [self._target_file_path(h) for h in generated_hdrs]
                self.attr['generated_hdrs'] = generated_hdrs
                cc_targets._declare_hdrs(self, generated_hdrs)

        if export_incs:
            self.attr['export_incs'] = self._expand_incs(var_to_list(export_incs))