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

Unified Diff: tools/gn/action_target_generator.cc

Issue 429423002: Refactor GN source expansions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/action_target_generator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/action_target_generator.cc
diff --git a/tools/gn/action_target_generator.cc b/tools/gn/action_target_generator.cc
index 0ad3928ad5a9cc20772b5814cefe247050d98f21..bbe413c98bf8e35c4f339a047654cc27cd99271d 100644
--- a/tools/gn/action_target_generator.cc
+++ b/tools/gn/action_target_generator.cc
@@ -13,21 +13,6 @@
#include "tools/gn/value_extractors.h"
#include "tools/gn/variables.h"
-namespace {
-
-// Returns true if the list of files looks like it might have a {{ }} pattern
-// in it. Used for error checking.
-bool StringListHasPattern(const std::vector<std::string>& files) {
- for (size_t i = 0; i < files.size(); i++) {
- if (files[i].find("{{") != std::string::npos &&
- files[i].find("}}") != std::string::npos)
- return true;
- }
- return false;
-}
-
-} // namespace
-
ActionTargetGenerator::ActionTargetGenerator(
Target* target,
Scope* scope,
@@ -67,7 +52,7 @@ void ActionTargetGenerator::DoRun() {
if (err_->has_error())
return;
- FillOutputs();
+ FillOutputs(output_type_ == Target::ACTION_FOREACH);
if (err_->has_error())
return;
@@ -108,8 +93,7 @@ void ActionTargetGenerator::FillScriptArgs() {
if (!value)
return;
- if (!ExtractListOfStringValues(*value, &target_->action_values().args(),
- err_))
+ if (!target_->action_values().args().Parse(*value, err_))
return;
}
@@ -117,14 +101,19 @@ void ActionTargetGenerator::FillDepfile() {
const Value* value = scope_->GetValue(variables::kDepfile, true);
if (!value)
return;
- target_->action_values().set_depfile(
- scope_->settings()->build_settings()->build_dir().ResolveRelativeFile(
- value->string_value()));
+
+ SubstitutionPattern depfile;
+ if (!depfile.Parse(*value, err_))
+ return;
+ if (!EnsureSubstitutionIsInOutputDir(depfile, *value))
+ return;
+
+ target_->action_values().set_depfile(depfile);
}
void ActionTargetGenerator::CheckOutputs() {
- const std::vector<std::string>& outputs = target_->action_values().outputs();
- if (outputs.empty()) {
+ const SubstitutionList& outputs = target_->action_values().outputs();
+ if (outputs.list().empty()) {
*err_ = Err(function_call_, "Action has no outputs.",
"If you have no outputs, the build system can not tell when your\n"
"script needs to be run.");
@@ -132,8 +121,7 @@ void ActionTargetGenerator::CheckOutputs() {
}
if (output_type_ == Target::ACTION) {
- // Make sure the outputs for an action have no patterns in them.
- if (StringListHasPattern(outputs)) {
+ if (!outputs.required_types().empty()) {
*err_ = Err(function_call_, "Action has patterns in the output.",
"An action target should have the outputs completely specified. If\n"
"you want to provide a mapping from source to output, use an\n"
@@ -142,7 +130,7 @@ void ActionTargetGenerator::CheckOutputs() {
}
} else if (output_type_ == Target::ACTION_FOREACH) {
// A foreach target should always have a pattern in the outputs.
- if (!StringListHasPattern(outputs)) {
+ if (outputs.required_types().empty()) {
*err_ = Err(function_call_,
"action_foreach should have a pattern in the output.",
"An action_foreach target should have a source expansion pattern in\n"
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/action_target_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698