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

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

Issue 1430043002: Support script response files in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/action_target_generator.h" 5 #include "tools/gn/action_target_generator.h"
6 6
7 #include "tools/gn/build_settings.h" 7 #include "tools/gn/build_settings.h"
8 #include "tools/gn/err.h" 8 #include "tools/gn/err.h"
9 #include "tools/gn/filesystem_utils.h" 9 #include "tools/gn/filesystem_utils.h"
10 #include "tools/gn/parse_tree.h" 10 #include "tools/gn/parse_tree.h"
(...skipping 30 matching lines...) Expand all
41 41
42 if (!FillInputs()) 42 if (!FillInputs())
43 return; 43 return;
44 44
45 if (!FillScript()) 45 if (!FillScript())
46 return; 46 return;
47 47
48 if (!FillScriptArgs()) 48 if (!FillScriptArgs())
49 return; 49 return;
50 50
51 if (!FillResponseFileContents())
52 return;
53
51 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH)) 54 if (!FillOutputs(output_type_ == Target::ACTION_FOREACH))
52 return; 55 return;
53 56
54 if (!FillDepfile()) 57 if (!FillDepfile())
55 return; 58 return;
56 59
57 if (!FillConsole()) 60 if (!FillConsole())
58 return; 61 return;
59 62
60 if (!FillCheckIncludes()) 63 if (!FillCheckIncludes())
61 return; 64 return;
62 65
63 if (!CheckOutputs()) 66 if (!CheckOutputs())
64 return; 67 return;
65 68
66 // Action outputs don't depend on the current toolchain so we can skip adding 69 // Action outputs don't depend on the current toolchain so we can skip adding
67 // that dependency. 70 // that dependency.
71
72 // response_file_contents and {{response_file_name}} in the args must go
73 // together.
74 const auto& required_args_substitutions =
75 target_->action_values().args().required_types();
76 bool has_rsp_file_name = std::find(
77 required_args_substitutions.begin(), required_args_substitutions.end(),
78 SUBSTITUTION_RSP_FILE_NAME) != required_args_substitutions.end();
scottmg 2015/11/04 22:35:33 this is weird formatting, did clang-format do this
79 if (target_->action_values().uses_rsp_file() && !has_rsp_file_name) {
80 *err_ = Err(function_call_, "Missing {{response_file_name}} in args.",
81 "This target defines response_file_contents but doesn't use\n"
82 "{{response_file_name}} in the args, which means the response file\n"
83 "will be unused.");
84 return;
85 }
86 if (!target_->action_values().uses_rsp_file() && has_rsp_file_name) {
87 *err_ = Err(function_call_, "Missing response_file_content definition.",
88 "This target uses {{response_file_name}} in the args, but does not\n"
89 "define response_file_content which means the response file\n"
90 "will be empty.");
91 return;
92 }
68 } 93 }
69 94
70 bool ActionTargetGenerator::FillScript() { 95 bool ActionTargetGenerator::FillScript() {
71 // If this gets called, the target type requires a script, so error out 96 // If this gets called, the target type requires a script, so error out
72 // if it doesn't have one. 97 // if it doesn't have one.
73 const Value* value = scope_->GetValue(variables::kScript, true); 98 const Value* value = scope_->GetValue(variables::kScript, true);
74 if (!value) { 99 if (!value) {
75 *err_ = Err(function_call_, "This target type requires a \"script\"."); 100 *err_ = Err(function_call_, "This target type requires a \"script\".");
76 return false; 101 return false;
77 } 102 }
(...skipping 10 matching lines...) Expand all
88 return true; 113 return true;
89 } 114 }
90 115
91 bool ActionTargetGenerator::FillScriptArgs() { 116 bool ActionTargetGenerator::FillScriptArgs() {
92 const Value* value = scope_->GetValue(variables::kArgs, true); 117 const Value* value = scope_->GetValue(variables::kArgs, true);
93 if (!value) 118 if (!value)
94 return true; 119 return true;
95 return target_->action_values().args().Parse(*value, err_); 120 return target_->action_values().args().Parse(*value, err_);
96 } 121 }
97 122
123 bool ActionTargetGenerator::FillResponseFileContents() {
124 const Value* value = scope_->GetValue(variables::kResponseFileContents, true);
125 if (!value)
126 return true;
127 return target_->action_values().rsp_file_contents().Parse(*value, err_);
128 }
129
98 bool ActionTargetGenerator::FillDepfile() { 130 bool ActionTargetGenerator::FillDepfile() {
99 const Value* value = scope_->GetValue(variables::kDepfile, true); 131 const Value* value = scope_->GetValue(variables::kDepfile, true);
100 if (!value) 132 if (!value)
101 return true; 133 return true;
102 134
103 SubstitutionPattern depfile; 135 SubstitutionPattern depfile;
104 if (!depfile.Parse(*value, err_)) 136 if (!depfile.Parse(*value, err_))
105 return false; 137 return false;
106 if (!EnsureSubstitutionIsInOutputDir(depfile, *value)) 138 if (!EnsureSubstitutionIsInOutputDir(depfile, *value))
107 return false; 139 return false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 *err_ = Err(function_call_, 175 *err_ = Err(function_call_,
144 "action_foreach should have a pattern in the output.", 176 "action_foreach should have a pattern in the output.",
145 "An action_foreach target should have a source expansion pattern in\n" 177 "An action_foreach target should have a source expansion pattern in\n"
146 "it to map source file to unique output file name. Otherwise, the\n" 178 "it to map source file to unique output file name. Otherwise, the\n"
147 "build system can't determine when your script needs to be run."); 179 "build system can't determine when your script needs to be run.");
148 return false; 180 return false;
149 } 181 }
150 } 182 }
151 return true; 183 return true;
152 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698