[Apple] Fix `gn gen` when using swift and no_stamp_files When using swift source files, the outputs cannot be derived from the sources (due to the "whole module optimisation" model). This caused `gn gen` to fail an assertion when using no_stamp_files and whole module optimisation. Without this change, generating the build for the sample project (in //examples/ios) would fail like this: $ ../../out/gn gen out [...:FATAL:ninja_c_binary_target_writer.cc(539)] Check failed: swiftmodule->has_dependency_output(). [...:FATAL:ninja_target_writer.cc(626)] Check failed: files.empty(). [...:FATAL:ninja_c_binary_target_writer.cc(539)] Check failed: swiftmodule->has_dependency_output(). Fix this by ensuring HasRealInputs() returns true when the source_set contains any swift source files. Bug: none Change-Id: Icb748717e1bcb301e3e32fdbba5293f2d09ad69d Reviewed-on: https://gn-review.googlesource.com/c/gn/+/19580 Commit-Queue: Sylvain Defresne <sdefresne@chromium.org> Reviewed-by: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/target.cc b/src/gn/target.cc index 6cb5572..1ea1298 100644 --- a/src/gn/target.cc +++ b/src/gn/target.cc
@@ -931,6 +931,11 @@ std::vector<OutputFile> tool_outputs; return std::any_of( sources().begin(), sources().end(), [&, this](const auto& source) { + // Swift files always results in output files, but the name cannot + // be derived from the source file via GetOutputFilesForSource(...). + if (source.GetType() == SourceFile::SOURCE_SWIFT) { + return true; + } const char* tool_name = Tool::kToolNone; return GetOutputFilesForSource(source, &tool_name, &tool_outputs); });