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/target_generator.cc

Issue 1155303008: Allow directories for GN data lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@path
Patch Set: add dir test Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/target_generator.cc
diff --git a/tools/gn/target_generator.cc b/tools/gn/target_generator.cc
index f59a21bc25efe0c7c37acfb62856be4b012725da..6018147d4c43512b4b5e6da1ad3b1bce0eb18255 100644
--- a/tools/gn/target_generator.cc
+++ b/tools/gn/target_generator.cc
@@ -201,12 +201,40 @@ bool TargetGenerator::FillData() {
const Value* value = scope_->GetValue(variables::kData, true);
if (!value)
return true;
-
- Target::FileList dest_data;
- if (!ExtractListOfRelativeFiles(scope_->settings()->build_settings(), *value,
- scope_->GetSourceDir(), &dest_data, err_))
+ if (!value->VerifyTypeIs(Value::LIST, err_))
return false;
- target_->data().swap(dest_data);
+
+ const std::vector<Value>& input_list = value->list_value();
+ std::vector<std::string>& output_list = target_->data();
+ output_list.reserve(input_list.size());
+
+ const SourceDir& dir = scope_->GetSourceDir();
+ const std::string& root_path =
+ scope_->settings()->build_settings()->root_path_utf8();
+
+ for (size_t i = 0; i < input_list.size(); i++) {
+ const Value& input = input_list[i];
+ if (!input.VerifyTypeIs(Value::STRING, err_))
+ return false;
+ const std::string& input_str = input.string_value();
+
+ // Treat each input as either a file or a directory, depending on the
+ // last character.
+ if (!input_str.empty() && input_str[input_str.size() - 1] == '/') {
+ // Resolve as directory.
+ SourceDir resolved =
+ dir.ResolveRelativeDir(input, input_str, err_, root_path);
+ if (err_->has_error())
+ return false;
+ output_list.push_back(resolved.value());
+ } else {
+ // Resolve as file.
+ SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path);
+ if (err_->has_error())
+ return false;
+ output_list.push_back(resolved.value());
+ }
+ }
return true;
}
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698