Skip to content

Commit 29e1b83

Browse files
committed
[test] Move BlocksRuntimeStubs into its own folder under stdlib/.
BlocksRuntimeStubs is built for the target SDK(s), but it was using one of the stdlib CMake helpers without setting up the same environment as the stdlib/ folder is setting. To avoid problems, like BlocksRuntimeStubs being built with the host compiler, instead of the just built compiler, and other difficult to understand problems, create a folder for it in stdlib/private/. This will allow the usage of the stdlib CMake function in the same environment that is normally used.
1 parent c869cbf commit 29e1b83

File tree

4 files changed

+48
-23
lines changed

4 files changed

+48
-23
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void
2+
#if defined(_WIN32)
3+
__declspec(dllexport)
4+
#endif
5+
_Block_release(void) { }
6+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/cmake/modules")
2+
3+
include(SwiftTestUtils)
4+
5+
foreach(SDK ${SWIFT_SDKS})
6+
foreach(ARCH ${SWIFT_SDK_${SDK}_ARCHITECTURES})
7+
get_swift_test_build_flavors(build_flavors "${SDK}")
8+
9+
foreach(BUILD_FLAVOR build_flavors)
10+
get_swift_test_variant_suffix(VARIANT_SUFFIX "${SDK}" "${ARCH}" "${BUILD_FLAVOR}")
11+
12+
set(test_bin_dir "${CMAKE_BINARY_DIR}/test${VARIANT_SUFFIX}")
13+
14+
_add_swift_target_library_single(
15+
BlocksRuntimeStub${VARIANT_SUFFIX}
16+
BlocksRuntimeStub
17+
SHARED
18+
ARCHITECTURE ${ARCH}
19+
SDK ${SDK}
20+
INSTALL_IN_COMPONENT dev
21+
BlocksRuntime.c
22+
)
23+
set_target_properties(BlocksRuntimeStub${VARIANT_SUFFIX} PROPERTIES
24+
ARCHIVE_OUTPUT_DIRECTORY ${test_bin_dir}
25+
LIBRARY_OUTPUT_DIRECTORY ${test_bin_dir}
26+
RUNTIME_OUTPUT_DIRECTORY ${test_bin_dir}
27+
OUTPUT_NAME BlocksRuntime)
28+
endforeach()
29+
endforeach()
30+
endforeach()
31+

stdlib/private/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ if(SWIFT_BUILD_SDK_OVERLAY)
2929
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
3030
add_subdirectory(StdlibUnittestFoundationExtras)
3131
endif()
32-
# Currently SwiftReflectionTest cannot be built on Windows, due to
33-
# dependencies on POSIX symbols
32+
# Currently SwiftReflectionTest cannot be built on Windows, due to
33+
# dependencies on POSIX symbols
3434
if (SWIFT_INCLUDE_TESTS AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"))
3535
add_subdirectory(SwiftReflectionTest)
3636
endif()
3737
endif()
38+
39+
# Keep in sync with stdlib/tools/CMakeLists.txt: swift-reflection-test is
40+
# only used when testing dynamic stdlib.
41+
if(SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_INCLUDE_TESTS)
42+
# NOTE create a stub BlocksRuntime library that can be used for the
43+
# reflection tests
44+
add_subdirectory(BlocksRuntimeStubs)
45+
endif()
46+

test/CMakeLists.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,27 +249,6 @@ foreach(SDK ${SWIFT_SDKS})
249249
# Keep in sync with stdlib/tools/CMakeLists.txt: swift-reflection-test is
250250
# only used when testing dynamic stdlib.
251251
if(SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_INCLUDE_TESTS)
252-
# NOTE create a stub BlocksRuntime library that can be used for the
253-
# reflection tests
254-
file(WRITE ${test_bin_dir}/Inputs/BlocksRuntime.c
255-
"void
256-
#if defined(_WIN32)
257-
__declspec(dllexport)
258-
#endif
259-
_Block_release(void) { }\n")
260-
_add_swift_target_library_single(
261-
BlocksRuntimeStub${VARIANT_SUFFIX}
262-
BlocksRuntimeStub
263-
SHARED
264-
ARCHITECTURE ${ARCH}
265-
SDK ${SDK}
266-
INSTALL_IN_COMPONENT dev
267-
${test_bin_dir}/Inputs/BlocksRuntime.c)
268-
set_target_properties(BlocksRuntimeStub${VARIANT_SUFFIX} PROPERTIES
269-
ARCHIVE_OUTPUT_DIRECTORY ${test_bin_dir}
270-
LIBRARY_OUTPUT_DIRECTORY ${test_bin_dir}
271-
RUNTIME_OUTPUT_DIRECTORY ${test_bin_dir}
272-
OUTPUT_NAME BlocksRuntime)
273252
list(APPEND test_dependencies BlocksRuntimeStub${VARIANT_SUFFIX})
274253

275254
list(APPEND test_dependencies

0 commit comments

Comments
 (0)