summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/Swift/RunCMakeTest.cmake
diff options
context:
space:
mode:
authorEvan Wilde <etceterawilde@gmail.com>2023-01-16 07:25:20 (GMT)
committerEvan Wilde <etceterawilde@gmail.com>2023-01-21 18:37:09 (GMT)
commit1730d208b5c94c600f08241a47cb41f81f4db097 (patch)
tree9550dafabffba4074ee63d133a6cbc4172641ff6 /Tests/RunCMake/Swift/RunCMakeTest.cmake
parentbf3a8ef6d59946a5479b5d8eb554cdb05e56bb2b (diff)
downloadCMake-1730d208b5c94c600f08241a47cb41f81f4db097.zip
CMake-1730d208b5c94c600f08241a47cb41f81f4db097.tar.gz
CMake-1730d208b5c94c600f08241a47cb41f81f4db097.tar.bz2
Add incremental Swift static lib build test
Ensure that we're actually trying to rebuild libB when the public interface for libA changes. Without handling the swiftmodule dependency edge correctly, we would only get a linker error because libA didn't have the symbol that libB depended on. With the fix, we get a proper compiler error because ninja knows to rebuild the intermediate libB when the public interface of libA changes. This is more actionable.
Diffstat (limited to 'Tests/RunCMake/Swift/RunCMakeTest.cmake')
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake21
1 files changed, 21 insertions, 0 deletions
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index 7f4464d..5537c01 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -24,6 +24,27 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .)
run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain)
endblock()
+
+ # Test that intermediate static libraries are rebuilt when the public
+ # interface of their dependency changes
+ block()
+ set(IncrementalSwift_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncrementalSwift-build)
+ set(IncrementalSwift_TEST_NO_CLEAN 1)
+ set(IncrementalSwift_TEST_OUTPUT_MERGE 1)
+ # Since files are modified during test, the files are created in the cmake
+ # file into the build directory
+ run_cmake(IncrementalSwift)
+ run_cmake_command(IncrementalSwift-first ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR})
+
+ # Modify public interface of libA requiring rebuild of libB
+ file(WRITE ${IncrementalSwift_TEST_BINARY_DIR}/a.swift
+ "public func callA() -> Float { return 32.0 }\n")
+
+ # Note: We still expect this to fail, but instead of failure at link time,
+ # it should fail while re-compiling libB because the function changed
+ run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR} -- -d explain)
+ endblock()
+
endif()
elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config")
if(CMAKE_Swift_COMPILER)