Move runtime_deps file for phony targets to /obj
For targets that use phony aliases, we generate a dependency_output in
the PHONY BuildDir. Since this doesn't actually create any files, the
"phony" directory is never actually generated. However, when the caller
requests runtime_deps files to be written, the phony target path was
being used to generate the runtime_deps file name. This resulted in
out/phony/foo/bar.runtime_deps being generated.
This CL fixes the runtime_deps file path for phony targets to be in the
OBJ BuildDir.
Change-Id: I3ac9fcc2597241b1bb4ce85cf8c57ad2a1b1e24c
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/10181
Commit-Queue: Petr Hosek <phosek@google.com>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/docs/reference.md b/docs/reference.md
index 7438d9c..93cba60 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -2658,7 +2658,7 @@
process_file_template").
source sets and groups: this will return a list containing the path of the
- "stamp" file that Ninja will produce once all outputs are generated. This
+ phony target that Ninja completes once all outputs are generated. This
probably isn't very useful.
```
diff --git a/src/gn/runtime_deps.cc b/src/gn/runtime_deps.cc
index d002458..1213c35 100644
--- a/src/gn/runtime_deps.cc
+++ b/src/gn/runtime_deps.cc
@@ -185,9 +185,15 @@
CHECK(!target->computed_outputs().empty());
output_file =
OutputFile(target->computed_outputs()[0].value() + extension);
- } else if (target->dependency_output_file_or_phony()) {
- output_file = OutputFile(
- target->dependency_output_file_or_phony()->value() + extension);
+ } else if (target->dependency_output_file()) {
+ output_file =
+ OutputFile(target->dependency_output_file()->value() + extension);
+ } else if (target->dependency_output_phony()) {
+ // If the dependency is a phony target, there is no file to add an additional
+ // extension to, so we should compute our own name in the OBJ BuildDir.
+ output_file = GetBuildDirForTargetAsOutputFile(target, BuildDirType::OBJ);
+ output_file->value().append(target->GetComputedOutputName());
+ output_file->value().append(extension);
}
if (output_file)
files_to_write->push_back(std::make_pair(*output_file, target));
diff --git a/src/gn/switches.cc b/src/gn/switches.cc
index abbc0e4..2b42e13 100644
--- a/src/gn/switches.cc
+++ b/src/gn/switches.cc
@@ -198,10 +198,12 @@
an output file "bar.so", GN will create a file "bar.so.runtime_deps" in the
build directory.
- If a source set, action, copy, or group is listed, the runtime deps file will
- correspond to the phony alias rule corresponding to that target. This is
- probably not useful; the use-case for this feature is generally executable
- targets.
+ For targets that don't generate an output file (such as source set, action,
+ copy or group), the runtime deps file will be in the output directory where an
+ output file would have been located. For example, the source_set target
+ "//foo:bar" would result in a runtime dependency file being written to
+ "<output_dir>/obj/foo/bar.runtime_deps". This is probably not useful; the
+ use-case for this feature is generally executable targets.
The runtime dependency file will list one file per line, with no escaping.
The files will be relative to the root_build_dir. The first line of the file