Replace command buffer FlushSync with WaitForTokenInRange and WaitForGetOffsetInRange
[chromium-blink-merge.git] / tools / gn / ninja_copy_target_writer.cc
blob89b3e3fb52dfa7656594bcf8b1ac015c8906b6db
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/gn/ninja_copy_target_writer.h"
7 #include "base/strings/string_util.h"
8 #include "tools/gn/file_template.h"
9 #include "tools/gn/string_utils.h"
11 NinjaCopyTargetWriter::NinjaCopyTargetWriter(const Target* target,
12 const Toolchain* toolchain,
13 std::ostream& out)
14 : NinjaTargetWriter(target, toolchain, out) {
17 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() {
20 void NinjaCopyTargetWriter::Run() {
21 CHECK(target_->script_values().outputs().size() == 1);
22 FileTemplate output_template(GetOutputTemplate());
24 std::vector<OutputFile> output_files;
26 std::string rule_prefix = helper_.GetRulePrefix(target_->settings());
28 for (size_t i = 0; i < target_->sources().size(); i++) {
29 const SourceFile& input_file = target_->sources()[i];
31 // Make the output file from the template.
32 std::vector<std::string> template_result;
33 output_template.ApplyString(input_file.value(), &template_result);
34 CHECK(template_result.size() == 1);
35 OutputFile output_file(template_result[0]);
37 output_files.push_back(output_file);
39 out_ << "build ";
40 path_output_.WriteFile(out_, output_file);
41 out_ << ": " << rule_prefix << "copy ";
42 path_output_.WriteFile(out_, input_file);
43 out_ << std::endl;
46 // Write out the rule for the target to copy all of them.
47 out_ << std::endl << "build ";
48 path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_));
49 out_ << ": " << rule_prefix << "stamp";
50 for (size_t i = 0; i < output_files.size(); i++) {
51 out_ << " ";
52 path_output_.WriteFile(out_, output_files[i]);
54 out_ << std::endl;