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

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: Add unit tests & support for bundle_data_filter Created 4 years, 10 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 : NinjaTargetWriter(target, out), tool_type_(tool_type) {
20 } 21 }
21 22
22 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() { 23 NinjaCopyTargetWriter::~NinjaCopyTargetWriter() {
23 } 24 }
24 25
25 void NinjaCopyTargetWriter::Run() { 26 void NinjaCopyTargetWriter::Run() {
26 const Tool* copy_tool = target_->toolchain()->GetTool(Toolchain::TYPE_COPY); 27 const Tool* copy_tool = target_->toolchain()->GetTool(tool_type_);
27 if (!copy_tool) { 28 if (!copy_tool) {
28 g_scheduler->FailWithError(Err( 29 g_scheduler->FailWithError(Err(
29 nullptr, "Copy tool not defined", 30 nullptr, "Copy tool not defined",
30 "The toolchain " + 31 "The toolchain " +
31 target_->toolchain()->label().GetUserVisibleName(false) + 32 target_->toolchain()->label().GetUserVisibleName(false) +
32 "\n used by target " + target_->label().GetUserVisibleName(false) + 33 "\n used by target " + target_->label().GetUserVisibleName(false) +
33 "\n doesn't define a \"copy\" tool.")); 34 "\n doesn't define a \"copy\" tool."));
34 return; 35 return;
35 } 36 }
36 37
(...skipping 23 matching lines...) Expand all
60 61
61 void NinjaCopyTargetWriter::WriteCopyRules( 62 void NinjaCopyTargetWriter::WriteCopyRules(
62 std::vector<OutputFile>* output_files) { 63 std::vector<OutputFile>* output_files) {
63 CHECK(target_->action_values().outputs().list().size() == 1); 64 CHECK(target_->action_values().outputs().list().size() == 1);
64 const SubstitutionList& output_subst_list = 65 const SubstitutionList& output_subst_list =
65 target_->action_values().outputs(); 66 target_->action_values().outputs();
66 CHECK_EQ(1u, output_subst_list.list().size()) 67 CHECK_EQ(1u, output_subst_list.list().size())
67 << "Should have one entry exactly."; 68 << "Should have one entry exactly.";
68 const SubstitutionPattern& output_subst = output_subst_list.list()[0]; 69 const SubstitutionPattern& output_subst = output_subst_list.list()[0];
69 70
70 std::string tool_name = 71 std::string tool_name = GetNinjaRulePrefixForToolchain(settings_) +
71 GetNinjaRulePrefixForToolchain(settings_) + 72 Toolchain::ToolTypeToName(tool_type_);
72 Toolchain::ToolTypeToName(Toolchain::TYPE_COPY);
73 73
74 OutputFile input_dep = 74 OutputFile input_dep =
75 WriteInputDepsStampAndGetDep(std::vector<const Target*>()); 75 WriteInputDepsStampAndGetDep(std::vector<const Target*>());
76 76
77 // Note that we don't write implicit deps for copy steps. "copy" only 77 // Note that we don't write implicit deps for copy steps. "copy" only
78 // depends on the output files themselves, rather than having includes 78 // depends on the output files themselves, rather than having includes
79 // (the possibility of generated #includes is the main reason for implicit 79 // (the possibility of generated #includes is the main reason for implicit
80 // dependencies). 80 // dependencies).
81 // 81 //
82 // It would seem that specifying implicit dependencies on the deps of the 82 // 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); 110 path_output_.WriteFile(out_, output_file);
111 out_ << ": " << tool_name << " "; 111 out_ << ": " << tool_name << " ";
112 path_output_.WriteFile(out_, input_file); 112 path_output_.WriteFile(out_, input_file);
113 if (!input_dep.value().empty()) { 113 if (!input_dep.value().empty()) {
114 out_ << " || "; 114 out_ << " || ";
115 path_output_.WriteFile(out_, input_dep); 115 path_output_.WriteFile(out_, input_dep);
116 } 116 }
117 out_ << std::endl; 117 out_ << std::endl;
118 } 118 }
119 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698