From d31b48816c4f01b4338a6044aa8f0d3575e19f70 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Mon, 18 Dec 2023 19:26:41 -0800 Subject: Swift/Ninja: Fix missing OFM in CMP0157 OLD behavior The CMP0157 old behavior omitted the output-file-map after the Swift build split because we stopped calling `EmitSwiftDependencyInfo` when we could not split the build because we didn't call `WriteObjectBuildStatement`. If we can't split the build, then we still need to include the OFM information to not break incremental builds. --- Source/cmNinjaTargetGenerator.cxx | 3 ++- Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt | 1 + Tests/RunCMake/Swift/RunCMakeTest.cmake | 14 +++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 732593f..2cb1284 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1142,7 +1142,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( std::vector swiftSources; for (cmSourceFile const* sf : objectSources) { - if (sf->GetLanguage() == "Swift") { + if (this->GetLocalGenerator()->IsSplitSwiftBuild() && + sf->GetLanguage() == "Swift") { swiftSources.push_back(sf); } else { this->WriteObjectBuildStatement(sf, config, fileConfig, diff --git a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt new file mode 100644 index 0000000..0955c61 --- /dev/null +++ b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt @@ -0,0 +1 @@ +swiftc .* -output-file-map CMakeFiles/greetings_default.dir//output-file-map.json .* diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 68d10ea..184b461 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -49,9 +49,17 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja) run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR} -- -d explain) endblock() - run_cmake(CMP0157-NEW) - run_cmake(CMP0157-OLD) - run_cmake(CMP0157-WARN) + block() + set(CMP0157-OLD_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build) + set(CMP0157-OLD_TEST_NO_CLEAN 1) + set(CMP0157-OLD_TEST_OUTPUT_MERGE 1) + + run_cmake(CMP0157-NEW) + run_cmake(CMP0157-OLD) + # -n: dry-run to avoid actually compiling, -v: verbose to capture executed command + run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build ${CMP0157-OLD_TEST_BINARY_DIR} -- -n -v) + run_cmake(CMP0157-WARN) + endblock() endif() elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") -- cgit v0.12