Skip to content

Commit ea90256

Browse files
committed
[android] Allow BlocksRuntimeStub to compile for Android
The target was correctly set for compiling, but was missing for linking, so the Android was trying to be link against the host tools machine. The solution uses _add_swift_library_single from AddSwift.cmake, which should handle all the supported SDK/Archs.
1 parent 473f3d2 commit ea90256

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ function(_add_variant_link_flags)
467467
endif()
468468

469469
if(NOT "${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_UC}" STREQUAL "")
470-
get_filename_component(SWIFT_${sdk}_${arch}_ICU_UC_LIBDIR "${SWIFT_${sdk}_${arch}_ICU_UC}" DIRECTORY)
471-
list(APPEND library_search_directories "${SWIFT_${sdk}_${arch}_ICU_UC_LIBDIR}")
470+
get_filename_component(SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_UC_LIBDIR
471+
"${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_UC}" DIRECTORY)
472+
list(APPEND library_search_directories "${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_UC_LIBDIR}")
472473
endif()
473474
if(NOT "${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_I18N}" STREQUAL "")
474-
get_filename_component(SWIFT_${sdk}_${arch}_ICU_I18N_LIBDIR "${SWIFT_${sdk}_${arch}_ICU_I18N}" DIRECTORY)
475-
list(APPEND library_search_directories "${SWIFT_${sdk}_${arch}_ICU_I18N_LIBDIR}")
475+
get_filename_component(SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_I18N_LIBDIR
476+
"${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_I18N}" DIRECTORY)
477+
list(APPEND library_search_directories "${SWIFT_${LFLAGS_SDK}_${LFLAGS_ARCH}_ICU_I18N_LIBDIR}")
476478
endif()
477479

478480
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)

test/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,16 @@ foreach(SDK ${SWIFT_SDKS})
204204
__declspec(dllexport)
205205
#endif
206206
_Block_release(void) { }\n")
207-
add_library(BlocksRuntimeStub-${SDK}-${ARCH} SHARED
207+
_add_swift_library_single(
208+
BlocksRuntimeStub-${SDK}-${ARCH}
209+
BlocksRuntimeStub
210+
SHARED
211+
DONT_EMBED_BITCODE
212+
NOSWIFTRT
213+
ARCHITECTURE ${ARCH}
214+
SDK ${SDK}
215+
INSTALL_IN_COMPONENT dev
208216
${test_bin_dir}/BlocksRuntime.c)
209-
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND
210-
NOT CMAKE_C_COMPILER_SIMULATE_ID STREQUAL MSVC)
211-
target_compile_options(BlocksRuntimeStub-${SDK}-${ARCH} PRIVATE
212-
-target;${SWIFT_SDK_${SDK}_ARCH_${ARCH}_TRIPLE})
213-
endif()
214217
set_target_properties(BlocksRuntimeStub-${SDK}-${ARCH} PROPERTIES
215218
ARCHIVE_OUTPUT_DIRECTORY ${test_bin_dir}
216219
LIBRARY_OUTPUT_DIRECTORY ${test_bin_dir}

0 commit comments

Comments
 (0)