Esempio n. 1
0
 def generate_rule(self,
                   name,
                   command,
                   description=None,
                   depfile=None,
                   generator=False,
                   pool=None,
                   restat=False,
                   rspfile=None,
                   rspfile_content=None,
                   deps=None):
     self._add_rule('rule %s' % name)
     self._add_rule('  command = %s' % command)
     if description:
         self._add_rule('  description = %s%s%s' %
                        (console.colors('dimpurple'), description,
                         console.colors('end')))
     if depfile:
         self._add_rule('  depfile = %s' % depfile)
     if generator:
         self._add_rule('  generator = 1')
     if pool:
         self._add_rule('  pool = %s' % pool)
     if restat:
         self._add_rule('  restat = 1')
     if rspfile:
         self._add_rule('  rspfile = %s' % rspfile)
     if rspfile_content:
         self._add_rule('  rspfile_content = %s' % rspfile_content)
     if deps:
         self._add_rule('  deps = %s' % deps)
Esempio n. 2
0
    def ninja_rules(self):
        rule = '%s__rule__' % self._regular_variable_name(
            self._source_file_path(self.name))
        cmd = self.ninja_command()
        description = '%sCOMMAND //%s%s' % (
            console.colors('dimpurple'), self.fullname, console.colors('end'))
        self._write_rule('''rule %s
  command = %s && cd %s && ls ${out} > /dev/null
  description = %s
''' % (rule, cmd, self.blade.get_root_dir(), description))
        outputs = [self._target_file_path(o) for o in self.data['outs']]
        inputs = [self._source_file_path(s) for s in self.srcs]
        vars = {}
        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')]
Esempio n. 3
0
 def _query_dependency_tree(self, key, level, build_targets):
     """Query the dependency tree of the specified target recursively. """
     path, name = key
     if level == 0:
         output = '%s:%s' % (path, name)
     elif level == 1:
         output = '%s %s:%s' % ('+-', path, name)
     else:
         output = '%s%s %s:%s' % ('|  ' * (level - 1), '+-', path, name)
     console.info(console.colors('end') + console.colors('gray') + output)
     for dkey in build_targets[key].deps:
         self._query_dependency_tree(dkey, level + 1, build_targets)
Esempio n. 4
0
 def _query_dependency_tree(self, key, level, build_targets):
     """Query the dependency tree of the specified target recursively. """
     path, name = key
     if level == 0:
         output = '%s:%s' % (path, name)
     elif level == 1:
         output = '%s %s:%s' % ('+-', path, name)
     else:
         output = '%s%s %s:%s' % ('|  ' * (level - 1), '+-', path, name)
     console.info(console.colors('end') + console.colors('gray') + output)
     for dkey in build_targets[key].deps:
         self._query_dependency_tree(dkey, level + 1, build_targets)
Esempio n. 5
0
def error_colorize(message):
    colored_message = []
    for t in message.splitlines(True):
        color = 'cyan'

        # For clang column indicator, such as '^~~~~~'
        if t.strip().startswith('^'):
            color = 'green'
        else:
            for w in _WARNINGS:
                if w in t:
                    color = 'yellow'
                    break
            for w in _ERRORS:
                if w in t:
                    color = 'red'
                    break

        colored_message.append(console.colors(color))
        colored_message.append(t)
        colored_message.append(console.colors('end'))
    return console.inerasable(''.join(colored_message))
Esempio n. 6
0
def error_colorize(message):
    colored_message = []
    for t in message.splitlines(True):
        color = 'cyan'

        # For clang column indicator, such as '^~~~~~'
        if t.strip().startswith('^'):
            color = 'green'
        else:
            for w in _WARNINGS:
                if w in t:
                    color = 'yellow'
                    break
            for w in _ERRORS:
                if w in t:
                    color = 'red'
                    break

        colored_message.append(console.colors(color))
        colored_message.append(t)
        colored_message.append(console.colors('end'))
    return console.inerasable(''.join(colored_message))