Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Side by Side Diff: tools/gn/ninja_copy_target_writer.cc

Issue 51693002: GN: toolchain threading cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/ninja_copy_target_writer.h ('k') | tools/gn/ninja_copy_target_writer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/ninja_copy_target_writer.h" 5 #include "tools/gn/ninja_copy_target_writer.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "tools/gn/file_template.h" 8 #include "tools/gn/file_template.h"
9 #include "tools/gn/string_utils.h" 9 #include "tools/gn/string_utils.h"
10 10
11 NinjaCopyTargetWriter::NinjaCopyTargetWriter(const Target* target, 11 NinjaCopyTargetWriter::NinjaCopyTargetWriter(const Target* target,
12 const Toolchain* toolchain,
12 std::ostream& out) 13 std::ostream& out)
13 : NinjaTargetWriter(target, out) { 14 : NinjaTargetWriter(target, toolchain, out) {
14 } 15 }
15 16
16 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() { 17 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() {
17 } 18 }
18 19
19 void NinjaCopyTargetWriter::Run() { 20 void NinjaCopyTargetWriter::Run() {
20 CHECK(target_->script_values().outputs().size() == 1); 21 CHECK(target_->script_values().outputs().size() == 1);
21 FileTemplate output_template(GetOutputTemplate()); 22 FileTemplate output_template(GetOutputTemplate());
22 23
23 std::vector<OutputFile> output_files; 24 std::vector<OutputFile> output_files;
24 25
25 std::string rule_prefix = 26 std::string rule_prefix = helper_.GetRulePrefix(target_->settings());
26 helper_.GetRulePrefix(target_->settings()->toolchain());
27 27
28 for (size_t i = 0; i < target_->sources().size(); i++) { 28 for (size_t i = 0; i < target_->sources().size(); i++) {
29 const SourceFile& input_file = target_->sources()[i]; 29 const SourceFile& input_file = target_->sources()[i];
30 30
31 // Make the output file from the template. 31 // Make the output file from the template.
32 std::vector<std::string> template_result; 32 std::vector<std::string> template_result;
33 output_template.ApplyString(input_file.value(), &template_result); 33 output_template.ApplyString(input_file.value(), &template_result);
34 CHECK(template_result.size() == 1); 34 CHECK(template_result.size() == 1);
35 OutputFile output_file(template_result[0]); 35 OutputFile output_file(template_result[0]);
36 36
37 output_files.push_back(output_file); 37 output_files.push_back(output_file);
38 38
39 out_ << "build "; 39 out_ << "build ";
40 path_output_.WriteFile(out_, output_file); 40 path_output_.WriteFile(out_, output_file);
41 out_ << ": " << rule_prefix << "copy "; 41 out_ << ": " << rule_prefix << "copy ";
42 path_output_.WriteFile(out_, input_file); 42 path_output_.WriteFile(out_, input_file);
43 out_ << std::endl; 43 out_ << std::endl;
44 } 44 }
45 45
46 // Write out the rule for the target to copy all of them. 46 // Write out the rule for the target to copy all of them.
47 out_ << std::endl << "build "; 47 out_ << std::endl << "build ";
48 path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_)); 48 path_output_.WriteFile(out_, helper_.GetTargetOutputFile(target_));
49 out_ << ": " << rule_prefix << "stamp"; 49 out_ << ": " << rule_prefix << "stamp";
50 for (size_t i = 0; i < output_files.size(); i++) { 50 for (size_t i = 0; i < output_files.size(); i++) {
51 out_ << " "; 51 out_ << " ";
52 path_output_.WriteFile(out_, output_files[i]); 52 path_output_.WriteFile(out_, output_files[i]);
53 } 53 }
54 out_ << std::endl; 54 out_ << std::endl;
55 } 55 }
OLDNEW
« no previous file with comments | « tools/gn/ninja_copy_target_writer.h ('k') | tools/gn/ninja_copy_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698