Skip to content

Commit 517f4b7

Browse files
authored
Merge pull request #34859 from drodriguez/test-blocks-runtime-stub-as-stdlib
[tests] Compile BlocksRuntimeStub with stdlib compiler settings
2 parents 4e39e59 + 0de902e commit 517f4b7

File tree

5 files changed

+298
-231
lines changed

5 files changed

+298
-231
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+

0 commit comments

Comments
 (0)