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

Unified Diff: tools/gn/target_generator.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, 11 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
Index: tools/gn/target_generator.cc
diff --git a/tools/gn/target_generator.cc b/tools/gn/target_generator.cc
index b1ed1ea3e3bcdfb1a49768580264d7ec67159b35..9b05ed796d57199ffce087610026bb000120d999 100644
--- a/tools/gn/target_generator.cc
+++ b/tools/gn/target_generator.cc
@@ -44,6 +44,9 @@ void TargetGenerator::Run() {
if (!FillData())
return;
+ if (!FillBundleData())
+ return;
+
if (!FillDependencies())
return;
@@ -87,8 +90,13 @@ void TargetGenerator::GenerateTarget(Scope* scope,
target->set_defined_from(function_call);
// Create and call out to the proper generator.
- if (output_type == functions::kCopy) {
- CopyTargetGenerator generator(target.get(), scope, function_call, err);
+ if (output_type == functions::kCopy ||
+ output_type == functions::kCopyBundleData) {
+ Target::OutputType target_output_type = output_type == functions::kCopy
+ ? Target::COPY_FILES
+ : Target::COPY_BUNDLE_DATA;
+ CopyTargetGenerator generator(target.get(), scope, function_call,
+ target_output_type, err);
generator.Run();
} else if (output_type == functions::kAction) {
ActionTargetGenerator generator(target.get(), scope, function_call,
@@ -241,6 +249,34 @@ bool TargetGenerator::FillData() {
return true;
}
+bool TargetGenerator::FillBundleData() {
+ const Value* value = scope_->GetValue(variables::kBundleData, true);
+ if (!value)
+ return true;
+
+ Target::FileList bundle_data;
+ if (!ExtractListOfRelativeFiles(scope_->settings()->build_settings(), *value,
+ scope_->GetSourceDir(), &bundle_data, err_))
+ return false;
+
+ target_->bundle_data().insert(bundle_data.begin(), bundle_data.end());
+ return true;
+}
+
+bool TargetGenerator::FillBundleDataFilter() {
+ const Value* value = scope_->GetValue(variables::kBundleDataFilter, true);
+ if (!value)
+ return true;
+
+ PatternList filter;
+ filter.SetFromValue(*value, err_);
+ if (err_->has_error())
+ return false;
+
+ std::swap(target_->bundle_data_filter(), filter);
+ return true;
+}
+
bool TargetGenerator::FillDependencies() {
if (!FillGenericDeps(variables::kDeps, &target_->private_deps()))
return false;

Powered by Google App Engine
This is Rietveld 408576698