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

Unified Diff: tools/gn/target.cc

Issue 1752033002: Add "create_bundle" target in order to support bundle with gn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-bundle-data
Patch Set: Add unit tests, address comments, update docs and format with clang-format Created 4 years, 9 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/target_generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
+ 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(
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/target_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698