Skip to content

Commit 11ec4df

Browse files
committed
[cmake] Add option for running tests against a just built toolchain.
The option is specifically: SWIFT_RUN_TESTS_WITH_HOST_COMPILER. NOTE: We assume that swiftc is in the just built toolchain directory and all necessary tools are next to swiftc. I am using this to bring up tests for a stage2 swift stdlib build (and eventual libswift support).
1 parent 719b112 commit 11ec4df

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
250250
"Use the host compiler and not the internal clang to build the swift runtime"
251251
FALSE)
252252

253+
option(SWIFT_RUN_TESTS_WITH_HOST_COMPILER
254+
"Run tests against the host compiler and not the just built swift"
255+
FALSE)
256+
253257
set(SWIFT_SDKS "" CACHE STRING
254258
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")
255259

test/CMakeLists.txt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,20 @@ set(SWIFT_LIT_ARGS "" CACHE STRING "Arguments to pass to lit")
134134
set(SWIFT_LIT_ENVIRONMENT "" CACHE STRING "Environment to use for lit invocations")
135135

136136
if(NOT SWIFT_INCLUDE_TOOLS)
137-
list(APPEND SWIFT_LIT_ARGS
138-
"--path=${SWIFT_NATIVE_LLVM_TOOLS_PATH}"
139-
"--path=${SWIFT_NATIVE_CLANG_TOOLS_PATH}"
140-
"--path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH}")
137+
if(SWIFT_RUN_TESTS_WITH_HOST_COMPILER)
138+
precondition(CMAKE_Swift_COMPILER MESSAGE "Can only run tests if a Swift compiler is specified")
139+
get_filename_component(SWIFT_COMPILER_DIR "${CMAKE_Swift_COMPILER}" DIRECTORY)
140+
precondition(SWIFT_COMPILER_DIR)
141+
# We assume that we are building against a toolchain where all tools are
142+
# next to swiftc.
143+
list(APPEND SWIFT_LIT_ARGS
144+
"--path=${SWIFT_COMPILER_DIR}")
145+
else()
146+
list(APPEND SWIFT_LIT_ARGS
147+
"--path=${SWIFT_NATIVE_LLVM_TOOLS_PATH}"
148+
"--path=${SWIFT_NATIVE_CLANG_TOOLS_PATH}"
149+
"--path=${SWIFT_NATIVE_SWIFT_TOOLS_PATH}")
150+
endif()
141151
if(SWIFT_BUILD_STDLIB)
142152
list(APPEND SWIFT_LIT_ARGS
143153
"--param" "test_resource_dir=${SWIFTLIB_DIR}")

0 commit comments

Comments
 (0)