Ejemplo n.º 1
0
 def _write_target_ninja_file(self, target, ninja_file, rules, rule_hash):
     """Generate per-target ninja file"""
     target_dir = target._target_file_path('')
     if not os.path.exists(target_dir):
         os.makedirs(target_dir)
     with open(ninja_file, 'w') as f:
         f.write('%s%s\n\n' % (_NINJA_FILE_RULE_HASH_START, rule_hash))
         f.writelines(rules)
Ejemplo n.º 2
0
    def _find_or_generate_target_ninja_file(self, target):
        target_ninja = target._target_file_path('%s.ninja' % target.name)
        old_rule_hash = self._read_rule_hash(target_ninja)
        rule_hash = target.rule_hash()
        if rule_hash == old_rule_hash:
            return target_ninja

        rules = target.get_rules()
        if rules:
            self._write_target_ninja_file(target, target_ninja, rules,
                                          rule_hash)
            return target_ninja

        return None
Ejemplo n.º 3
0
    def _find_or_generate_target_ninja_file(self, target):
        # The `.build.` infix is used to avoid the target ninja file with the
        # same name as the main build.ninja file (when target.name == 'build')
        target_ninja = target._target_file_path('%s.build.ninja' % target.name)

        old_rule_hash = self._read_rule_hash(target_ninja)
        rule_hash = target.rule_hash()

        if rule_hash == old_rule_hash:
            console.debug('Using cached %s' % target_ninja)
            # If the command is "clean", we still need to generate rules to obtain the clean list
            if self.__command == 'clean':
                target.get_rules()
            return target_ninja

        rules = target.get_rules()
        if rules:
            console.debug('Generating %s' % target_ninja)
            self._write_target_ninja_file(target, target_ninja, rules, rule_hash)
            return target_ninja

        return None