generated_file: add output to input deps of stamp By having outputs from generated file to input of stamp, dependency to output of generated_file target is properly handled by siso. Currently, we have siso config to collect inputs via transitive dependency like https://source.chromium.org/chromium/chromium/src/+/main:build/config/siso/mojo.star;l=45-53;drc=6041333279beac2504de56eb014ef888b79850a6 But we also need to have missing inputs list for some target like https://source.chromium.org/chromium/chromium/src/+/main:build/config/siso/mojo.star;l=59;drc=6041333279beac2504de56eb014ef888b79850a6 due to group target of parser_target_name doesn't have deps to build_metadata_filename in https://source.chromium.org/chromium/chromium/src/+/main:mojo/public/tools/bindings/mojom.gni;l=728;drc=1b561e6dca846e2b0ebf2c613b1bd94f76efdd5b To fix this, I changed to use generated_file instead of write_file in https://crrev.com/c/5772141. But to make siso recognize collect inputs for mojom_parser action, generated_file target needs to have deps to actual generated_file output in ninja file. Bug: b/288523418 Change-Id: If6dd5b3b5f6fffdab4fdeab93c76f7cd50d9ca4c Reviewed-on: https://gn-review.googlesource.com/c/gn/+/17500 Reviewed-by: Dirk Pranke <dpranke@google.com> Commit-Queue: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/ninja_generated_file_target_writer.cc b/src/gn/ninja_generated_file_target_writer.cc index 6c157e4..f09872e 100644 --- a/src/gn/ninja_generated_file_target_writer.cc +++ b/src/gn/ninja_generated_file_target_writer.cc
@@ -28,8 +28,9 @@ // A generated_file target should generate a stamp file with dependencies // on each of the deps and data_deps in the target. The actual collection is - // done at gen time, and so ninja doesn't need to know about it. - std::vector<OutputFile> output_files; + // done at gen time, but to have correct input deps in ninja, we add output + // from generated_file targets as deps for the stamp. + std::vector<OutputFile> output_files = target_->computed_outputs(); std::vector<OutputFile> data_output_files; const auto& target_deps = resolved().GetTargetDeps(target_); for (const Target* dep : target_deps.linked_deps()) {
diff --git a/src/gn/ninja_generated_file_target_writer_unittest.cc b/src/gn/ninja_generated_file_target_writer_unittest.cc index 676ba01..f883102 100644 --- a/src/gn/ninja_generated_file_target_writer_unittest.cc +++ b/src/gn/ninja_generated_file_target_writer_unittest.cc
@@ -63,7 +63,8 @@ writer.Run(); const char expected[] = - "build obj/foo/bar.stamp: stamp obj/foo/dep.stamp obj/foo/dep2.stamp || " + "build obj/foo/bar.stamp: stamp foo.json obj/foo/dep.stamp " + "obj/foo/dep2.stamp || " "obj/foo/bundle_data_dep.stamp obj/foo/datadep.stamp\n"; EXPECT_EQ(expected, out.str()); }