示例#1
0
    def export(self, writer, context, platform):
        """
    Export the target to a Ninja manifest.
    """

        writer.comment("target: {}".format(self.name))
        writer.comment("--------" + "-" * len(self.name))
        commands = platform.prepare_commands(
            [list(map(str, c)) for c in self.commands])

        # Check if we need to export a command file or can export the command
        # directly.
        if not self.environ and len(commands) == 1:
            commands = [platform.prepare_single_command(commands[0], self.cwd)]
        else:
            filename = path.join('.commands', self.name)
            command, __ = platform.write_command_file(filename,
                                                      commands,
                                                      self.inputs,
                                                      self.outputs,
                                                      cwd=self.cwd,
                                                      environ=self.environ,
                                                      foreach=self.foreach)
            commands = [command]

        assert len(commands) == 1
        command = shell.join(commands[0], for_ninja=True)

        writer.rule(self.name,
                    command,
                    pool=self.pool,
                    deps=self.deps,
                    depfile=self.depfile,
                    description=self.description)

        if self.msvc_deps_prefix:
            # We can not write msvc_deps_prefix on the rule level with Ninja
            # versions older than 1.7.1. Write it global instead, but that *could*
            # lead to issues...
            indent = 1 if context.ninja_version > '1.7.1' else 0
            writer.variable('msvc_deps_prefix', self.msvc_deps_prefix, indent)

        writer.newline()
        if self.foreach:
            assert len(self.inputs) == len(self.outputs)
            for infile, outfile in zip(self.inputs, self.outputs):
                writer.build([outfile],
                             self.name, [infile],
                             implicit=self.implicit_deps,
                             order_only=self.order_only_deps)
        else:
            writer.build(self.outputs or [self.name],
                         self.name,
                         self.inputs,
                         implicit=self.implicit_deps,
                         order_only=self.order_only_deps)

        if self.outputs and self.name not in self.outputs and not self.explicit:
            writer.build(self.name, 'phony', self.outputs)
示例#2
0
 def export(self, writer, context, platform):
   name = str(self)[1:]
   if not self.preamble and not self.environ:
     self.exported_command = shlex.join(self.command)
   else:
     filename = path.join('.tools', name)
     command, filename = platform.write_command_file(
         filename, list(self.preamble) + [self.command], environ=self.environ,
         accept_additional_args=True)
     self.exported_command = shell.join(command)
   writer.variable(name, self.exported_command)
示例#3
0
  def export(self, writer, context, platform):
    """
    Export the target to a Ninja manifest.
    """

    writer.comment("target: {}".format(self.name))
    writer.comment("--------" + "-" * len(self.name))
    commands = platform.prepare_commands([list(map(str, c)) for c in self.commands])

    # Check if we need to export a command file or can export the command
    # directly.
    if not self.environ and len(commands) == 1:
      commands = [platform.prepare_single_command(commands[0], self.cwd)]
    else:
      filename = path.join('.commands', self.name)
      command, __ = platform.write_command_file(filename, commands,
        self.inputs, self.outputs, cwd=self.cwd, environ=self.environ,
        foreach=self.foreach)
      commands = [command]

    assert len(commands) == 1
    command = shell.join(commands[0], for_ninja=True)

    writer.rule(self.name, command, pool=self.pool, deps=self.deps,
      depfile=self.depfile, description=self.description)

    if self.msvc_deps_prefix:
      # We can not write msvc_deps_prefix on the rule level with Ninja
      # versions older than 1.7.1. Write it global instead, but that *could*
      # lead to issues...
      indent = 1 if context.ninja_version > '1.7.1' else 0
      writer.variable('msvc_deps_prefix', self.msvc_deps_prefix, indent)

    writer.newline()
    if self.foreach:
      assert len(self.inputs) == len(self.outputs)
      for infile, outfile in zip(self.inputs, self.outputs):
        writer.build(
          [outfile],
          self.name,
          [infile],
          implicit=self.implicit_deps,
          order_only=self.order_only_deps)
    else:
      writer.build(
        self.outputs or [self.name],
        self.name,
        self.inputs,
        implicit=self.implicit_deps,
        order_only=self.order_only_deps)

    if self.outputs and self.name not in self.outputs and not self.explicit:
      writer.build(self.name, 'phony', self.outputs)
示例#4
0
 def export(self, writer, context, platform):
     name = str(self)[1:]
     if not self.preamble and not self.environ:
         self.exported_command = shell.join(self.command)
     else:
         filename = path.join('.tools', name)
         command, filename = platform.write_command_file(
             filename,
             list(self.preamble) + [self.command],
             environ=self.environ,
             accept_additional_args=True)
         self.exported_command = shell.join(command)
     writer.variable(name, self.exported_command)