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

Unified Diff: tools/gn/runtime_deps.cc

Issue 2178173002: Allow GN toolchains to specify runtime deps outputs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 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/gn.gyp ('k') | tools/gn/target.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/runtime_deps.cc
diff --git a/tools/gn/runtime_deps.cc b/tools/gn/runtime_deps.cc
index f350cb78a7c9b503ad7cef61f1c89118eefe65f4..1849117559c856aec97aa177760f1d5f96d80944 100644
--- a/tools/gn/runtime_deps.cc
+++ b/tools/gn/runtime_deps.cc
@@ -50,14 +50,6 @@ void AddIfNew(const std::string& str,
AddIfNew(output_file, source, deps, found_file);
}
-// Returns the output file that the runtime deps considers for the given
-// targets. This is weird only for shared libraries.
-const OutputFile& GetMainOutput(const Target* target) {
- if (target->output_type() == Target::SHARED_LIBRARY)
- return target->runtime_link_output_file();
- return target->dependency_output_file();
-}
-
// To avoid duplicate traversals of targets, or duplicating output files that
// might be listed by more than one target, the set of targets and output files
// that have been found so far is passed. The "value" of the seen_targets map
@@ -86,8 +78,10 @@ void RecursiveCollectRuntimeDeps(const Target* target,
// loadable modules.
if (target->output_type() == Target::EXECUTABLE ||
target->output_type() == Target::LOADABLE_MODULE ||
- target->output_type() == Target::SHARED_LIBRARY)
- AddIfNew(GetMainOutput(target), target, deps, found_files);
+ target->output_type() == Target::SHARED_LIBRARY) {
+ for (const auto& runtime_output : target->runtime_outputs())
+ AddIfNew(runtime_output, target, deps, found_files);
+ }
// Add all data files.
for (const auto& file : target->data())
@@ -173,8 +167,19 @@ bool CollectRuntimeDepsFromFlag(const Builder& builder,
return false;
}
- OutputFile output_file =
- OutputFile(GetMainOutput(target).value() + ".runtime_deps");
+ OutputFile output_file;
+ const char extension[] = ".runtime_deps";
+ if (target->output_type() == Target::SHARED_LIBRARY ||
+ target->output_type() == Target::LOADABLE_MODULE) {
+ // Force the first output for shared-library-type linker outputs since
+ // the dependency output files might not be the main output.
+ CHECK(!target->computed_outputs().empty());
+ output_file =
+ OutputFile(target->computed_outputs()[0].value() + extension);
+ } else {
+ output_file =
+ OutputFile(target->dependency_output_file().value() + extension);
+ }
files_to_write->push_back(std::make_pair(output_file, target));
}
return true;
@@ -262,11 +267,9 @@ const char kRuntimeDeps_Help[] =
"\n"
"Multiple outputs\n"
"\n"
- " When a tool produces more than one output, only the first output\n"
- " is considered. For example, a shared library target may produce a\n"
- " .dll and a .lib file on Windows. Only the .dll file will be considered\n"
- " a runtime dependency. This applies only to linker tools. Scripts and\n"
- " copy steps with multiple outputs will get all outputs listed.\n";
+ " Linker tools can specify which of their outputs should be considered\n"
+ " when computing the runtime deps by setting runtime_outputs. If this\n"
+ " is unset on the tool, the default will be the first output only.\n";
RuntimeDepsVector ComputeRuntimeDeps(const Target* target) {
RuntimeDepsVector result;
« no previous file with comments | « tools/gn/gn.gyp ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698