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

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

Issue 292123012: Add an error for empty script names in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // If this gets called, the target type requires a script, so error out 87 // If this gets called, the target type requires a script, so error out
88 // if it doesn't have one. 88 // if it doesn't have one.
89 const Value* value = scope_->GetValue(variables::kScript, true); 89 const Value* value = scope_->GetValue(variables::kScript, true);
90 if (!value) { 90 if (!value) {
91 *err_ = Err(function_call_, "This target type requires a \"script\"."); 91 *err_ = Err(function_call_, "This target type requires a \"script\".");
92 return; 92 return;
93 } 93 }
94 if (!value->VerifyTypeIs(Value::STRING, err_)) 94 if (!value->VerifyTypeIs(Value::STRING, err_))
95 return; 95 return;
96 96
97 target_->action_values().set_script( 97 SourceFile script_file =
98 scope_->GetSourceDir().ResolveRelativeFile(value->string_value())); 98 scope_->GetSourceDir().ResolveRelativeFile(value->string_value());
99 if (script_file.value().empty()) {
100 *err_ = Err(*value, "script name is empty");
101 return;
102 }
103 target_->action_values().set_script(script_file);
99 } 104 }
100 105
101 void ActionTargetGenerator::FillScriptArgs() { 106 void ActionTargetGenerator::FillScriptArgs() {
102 const Value* value = scope_->GetValue(variables::kArgs, true); 107 const Value* value = scope_->GetValue(variables::kArgs, true);
103 if (!value) 108 if (!value)
104 return; 109 return;
105 110
106 std::vector<std::string> args; 111 std::vector<std::string> args;
107 if (!ExtractListOfStringValues(*value, &args, err_)) 112 if (!ExtractListOfStringValues(*value, &args, err_))
108 return; 113 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!FileListHasPattern(outputs)) { 146 if (!FileListHasPattern(outputs)) {
142 *err_ = Err(function_call_, 147 *err_ = Err(function_call_,
143 "action_foreach should have a pattern in the output.", 148 "action_foreach should have a pattern in the output.",
144 "An action_foreach target should have a source expansion pattern in\n" 149 "An action_foreach target should have a source expansion pattern in\n"
145 "it to map source file to unique output file name. Otherwise, the\n" 150 "it to map source file to unique output file name. Otherwise, the\n"
146 "build system can't determine when your script needs to be run."); 151 "build system can't determine when your script needs to be run.");
147 return; 152 return;
148 } 153 }
149 } 154 }
150 } 155 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698