Index: tools/gn/target.cc |
diff --git a/tools/gn/target.cc b/tools/gn/target.cc |
index 9435d47ac59bfce8453c1e8216455f77f4cd27c2..714fd911f9657c038dda56c1b096ded0365d759c 100644 |
--- a/tools/gn/target.cc |
+++ b/tools/gn/target.cc |
@@ -224,6 +224,8 @@ const char* Target::GetStringForOutputType(OutputType type) { |
return "ActionForEach"; |
case BUNDLE_DATA: |
return "Bundle data"; |
+ case CREATE_BUNDLE: |
+ return "Create bundle"; |
default: |
return ""; |
} |
@@ -277,6 +279,7 @@ bool Target::OnResolved(Err* err) { |
all_libs_.append(cur.libs().begin(), cur.libs().end()); |
} |
+ PullRecursiveBundleData(); |
PullDependentTargetLibs(); |
PullRecursiveHardDeps(); |
if (!ResolvePrecompiledHeaders(err)) |
@@ -318,6 +321,7 @@ bool Target::IsFinal() const { |
output_type_ == ACTION || |
output_type_ == ACTION_FOREACH || |
output_type_ == COPY_FILES || |
+ output_type_ == CREATE_BUNDLE || |
(output_type_ == STATIC_LIBRARY && complete_static_lib_); |
} |
@@ -476,12 +480,48 @@ void Target::PullRecursiveHardDeps() { |
} |
} |
+void Target::PullRecursiveBundleData() { |
brettw
2016/03/02 21:12:42
We should have a unit test for this showing this g
sdefresne
2016/03/07 20:47:35
Done.
|
+ if (output_type_ != CREATE_BUNDLE) |
+ return; |
+ |
+ std::set<const Target*> visited; |
+ std::vector<const Target*> deps; |
+ deps.push_back(this); |
+ |
+ while (!deps.empty()) { |
+ const Target* current = deps.back(); |
+ deps.pop_back(); |
+ |
+ if (visited.find(current) != visited.end()) |
+ continue; |
+ visited.insert(current); |
+ |
+ if (current->output_type_ == BUNDLE_DATA) |
+ bundle_data_.AddFileRuleFromTarget(current); |
+ |
+ for (const LabelTargetPair& pair : current->GetDeps(DEPS_ALL)) { |
+ DCHECK(pair.ptr); |
+ DCHECK(pair.ptr->toolchain_); |
+ if (visited.find(pair.ptr) != visited.end()) |
+ continue; |
+ |
+ if (pair.ptr->output_type() == CREATE_BUNDLE) |
+ continue; |
+ |
+ deps.push_back(pair.ptr); |
+ } |
+ } |
+ |
+ bundle_data_.GetSourceFiles(&sources_); |
+} |
+ |
void Target::FillOutputFiles() { |
const Tool* tool = toolchain_->GetToolForTargetFinalOutput(this); |
bool check_tool_outputs = false; |
switch (output_type_) { |
case GROUP: |
case BUNDLE_DATA: |
+ case CREATE_BUNDLE: |
case SOURCE_SET: |
case COPY_FILES: |
case ACTION: |
@@ -547,6 +587,10 @@ void Target::FillOutputFiles() { |
NOTREACHED(); |
} |
+ // Count anything generated from bundle_data dependencies. |
+ if (output_type_ == CREATE_BUNDLE) |
+ bundle_data_.GetOutputFiles(settings(), &computed_outputs_); |
+ |
// Count all outputs from this tool as something generated by this target. |
if (check_tool_outputs) { |
SubstitutionWriter::ApplyListToLinkerAsOutputFile( |