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

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

Issue 1606553002: Add support for Mac/iOS application bundles to GN tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split CL to only include tool change & address comments Created 4 years, 11 months 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
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/ninja_utils.h" 8 #include "tools/gn/ninja_utils.h"
9 #include "tools/gn/output_file.h" 9 #include "tools/gn/output_file.h"
10 #include "tools/gn/scheduler.h" 10 #include "tools/gn/scheduler.h"
11 #include "tools/gn/string_utils.h" 11 #include "tools/gn/string_utils.h"
12 #include "tools/gn/substitution_list.h" 12 #include "tools/gn/substitution_list.h"
13 #include "tools/gn/substitution_writer.h" 13 #include "tools/gn/substitution_writer.h"
14 #include "tools/gn/target.h" 14 #include "tools/gn/target.h"
15 #include "tools/gn/toolchain.h" 15 #include "tools/gn/toolchain.h"
16 16
17 NinjaCopyTargetWriter::NinjaCopyTargetWriter(const Target* target, 17 NinjaCopyTargetWriter::NinjaCopyTargetWriter(const Target* target,
18 std::ostream& out) 18 std::ostream& out,
19 : NinjaTargetWriter(target, out) { 19 Toolchain::ToolType tool_type)
20 } 20 : NinjaTargetWriter(target, out), tool_type_(tool_type) {}
21 21
22 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() { 22 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() {
23 } 23 }
24 24
25 void NinjaCopyTargetWriter::Run() { 25 void NinjaCopyTargetWriter::Run() {
26 const Tool* copy_tool = target_->toolchain()->GetTool(Toolchain::TYPE_COPY); 26 const Tool* copy_tool = target_->toolchain()->GetTool(tool_type_);
27 if (!copy_tool) { 27 if (!copy_tool) {
28 g_scheduler->FailWithError(Err( 28 g_scheduler->FailWithError(Err(
29 nullptr, "Copy tool not defined", 29 nullptr, "Copy tool not defined",
30 "The toolchain " + 30 "The toolchain " +
31 target_->toolchain()->label().GetUserVisibleName(false) + 31 target_->toolchain()->label().GetUserVisibleName(false) +
32 "\n used by target " + target_->label().GetUserVisibleName(false) + 32 "\n used by target " + target_->label().GetUserVisibleName(false) +
33 "\n doesn't define a \"copy\" tool.")); 33 "\n doesn't define a \"copy\" tool."));
34 return; 34 return;
35 } 35 }
36 36
(...skipping 23 matching lines...) Expand all
60 60
61 void NinjaCopyTargetWriter::WriteCopyRules( 61 void NinjaCopyTargetWriter::WriteCopyRules(
62 std::vector<OutputFile>* output_files) { 62 std::vector<OutputFile>* output_files) {
63 CHECK(target_->action_values().outputs().list().size() == 1); 63 CHECK(target_->action_values().outputs().list().size() == 1);
64 const SubstitutionList& output_subst_list = 64 const SubstitutionList& output_subst_list =
65 target_->action_values().outputs(); 65 target_->action_values().outputs();
66 CHECK_EQ(1u, output_subst_list.list().size()) 66 CHECK_EQ(1u, output_subst_list.list().size())
67 << "Should have one entry exactly."; 67 << "Should have one entry exactly.";
68 const SubstitutionPattern& output_subst = output_subst_list.list()[0]; 68 const SubstitutionPattern& output_subst = output_subst_list.list()[0];
69 69
70 std::string tool_name = 70 std::string tool_name = GetNinjaRulePrefixForToolchain(settings_) +
71 GetNinjaRulePrefixForToolchain(settings_) + 71 Toolchain::ToolTypeToName(tool_type_);
72 Toolchain::ToolTypeToName(Toolchain::TYPE_COPY);
73 72
74 OutputFile input_dep = 73 OutputFile input_dep =
75 WriteInputDepsStampAndGetDep(std::vector<const Target*>()); 74 WriteInputDepsStampAndGetDep(std::vector<const Target*>());
76 75
77 // Note that we don't write implicit deps for copy steps. "copy" only 76 // Note that we don't write implicit deps for copy steps. "copy" only
78 // depends on the output files themselves, rather than having includes 77 // depends on the output files themselves, rather than having includes
79 // (the possibility of generated #includes is the main reason for implicit 78 // (the possibility of generated #includes is the main reason for implicit
80 // dependencies). 79 // dependencies).
81 // 80 //
82 // It would seem that specifying implicit dependencies on the deps of the 81 // It would seem that specifying implicit dependencies on the deps of the
(...skipping 27 matching lines...) Expand all
110 path_output_.WriteFile(out_, output_file); 109 path_output_.WriteFile(out_, output_file);
111 out_ << ": " << tool_name << " "; 110 out_ << ": " << tool_name << " ";
112 path_output_.WriteFile(out_, input_file); 111 path_output_.WriteFile(out_, input_file);
113 if (!input_dep.value().empty()) { 112 if (!input_dep.value().empty()) {
114 out_ << " || "; 113 out_ << " || ";
115 path_output_.WriteFile(out_, input_dep); 114 path_output_.WriteFile(out_, input_dep);
116 } 115 }
117 out_ << std::endl; 116 out_ << std::endl;
118 } 117 }
119 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698