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

Unified Diff: tools/gn/target.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.cc
diff --git a/tools/gn/target.cc b/tools/gn/target.cc
index 7dd192181ea891e96aa6a9762470fc63af02496e..a0bd986a563c19f07e622d800d69754b922dd025 100644
--- a/tools/gn/target.cc
+++ b/tools/gn/target.cc
@@ -218,6 +218,8 @@ const char* Target::GetStringForOutputType(OutputType type) {
return "Source set";
case COPY_FILES:
return "Copy";
+ case COPY_BUNDLE_DATA:
+ return "Copy bundle data";
case ACTION:
return "Action";
case ACTION_FOREACH:
@@ -275,6 +277,7 @@ bool Target::OnResolved(Err* err) {
all_libs_.append(cur.libs().begin(), cur.libs().end());
}
+ PullRecursiveBundleData();
PullDependentTargetLibs();
PullRecursiveHardDeps();
if (!ResolvePrecompiledHeaders(err))
@@ -316,6 +319,7 @@ bool Target::IsFinal() const {
output_type_ == ACTION ||
output_type_ == ACTION_FOREACH ||
output_type_ == COPY_FILES ||
+ output_type_ == COPY_BUNDLE_DATA ||
(output_type_ == STATIC_LIBRARY && complete_static_lib_);
}
@@ -474,6 +478,33 @@ void Target::PullRecursiveHardDeps() {
}
}
+void Target::PullRecursiveBundleData() {
+ for (const auto& pair : GetDeps(DEPS_LINKED)) {
+ if (pair.ptr->output_type() == EXECUTABLE ||
+ pair.ptr->output_type() == SHARED_LIBRARY ||
+ pair.ptr->output_type() == LOADABLE_MODULE ||
+ pair.ptr->output_type() == COPY_BUNDLE_DATA)
+ continue;
+
+ bundle_data_.insert(pair.ptr->bundle_data().begin(),
+ pair.ptr->bundle_data().end());
+ }
+
+ if (output_type_ != COPY_BUNDLE_DATA)
+ return;
+
+ const PatternList& filter = bundle_data_filter();
+ if (filter.is_empty()) {
+ sources_.insert(sources_.end(), bundle_data_.begin(), bundle_data_.end());
+ } else {
+ sources_.reserve(sources_.size() + bundle_data_.size());
+ for (const SourceFile& source_file : bundle_data_) {
+ if (!filter.MatchesString(source_file.value()))
+ sources_.push_back(source_file);
+ }
+ }
+}
+
void Target::FillOutputFiles() {
const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this);
bool check_tool_outputs = false;
@@ -481,6 +512,7 @@ void Target::FillOutputFiles() {
case GROUP:
case SOURCE_SET:
case COPY_FILES:
+ case COPY_BUNDLE_DATA:
case ACTION:
case ACTION_FOREACH: {
// These don't get linked to and use stamps which should be the first

Powered by Google App Engine
This is Rietveld 408576698