Example #1
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))
Example #2
0
    def __init__(self,
                 name,
                 srcs,
                 deps,
                 visibility,
                 outs,
                 cmd,
                 cmd_name,
                 generated_hdrs,
                 generated_incs,
                 export_incs,
                 heavy,
                 kwargs):
        """Init method.
        Init the gen rule target.
        """
        srcs = var_to_list(srcs)
        deps = var_to_list(deps)
        outs = [os.path.normpath(o) for o in var_to_list(outs)]

        super(GenRuleTarget, self).__init__(
                name=name,
                type='gen_rule',
                srcs=srcs,
                deps=deps,
                visibility=visibility,
                kwargs=kwargs)

        self.data['outs'] = outs
        self.data['locations'] = []
        self.data['cmd'] = LOCATION_RE.sub(self._process_location_reference, cmd)
        self.data['cmd_name'] = cmd_name
        self.data['heavy'] = heavy

        if generated_incs is not None:
            generated_incs = var_to_list(generated_incs)
            self.data['generated_incs'] = [self._target_file_path(inc) for inc in generated_incs]
        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.data['generated_hdrs'] = generated_hdrs

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