Start cross-compiling the new Swift Testing library on the CI for the… · finagolfin/swift-android-sdk@eb1567b (original) (raw)
`@@ -10,6 +10,43 @@ index 16e05052609..7ab8cebfab8 100755
`
10
10
``
11
11
` cmake_options=(
`
12
12
` -DENABLE_SWIFT=YES
`
``
13
`+
diff --git a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py b/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py
`
``
14
`+
index 324d1a77eea..e88601a8701 100644
`
``
15
`+
--- a/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py
`
``
16
`+
+++ b/swift/utils/swift_build_support/swift_build_support/products/swift_testing.py
`
``
17
`+
@@ -13,6 +13,9 @@
`
``
18
`+
import os
`
``
19
+
``
20
`+
from build_swift.build_swift.versions import Version
`
``
21
`+
+from ..host_specific_configuration \
`
``
22
`+
- import HostSpecificConfiguration
`
``
23
`+
+from ..targets import StdlibDeploymentTarget
`
``
24
+
``
25
`+
from . import cmake_product
`
``
26
`+
from . import product
`
``
27
`+
@@ -115,6 +117,22 @@ class SwiftTestingCMakeShim(cmake_product.CMakeProduct):
`
``
28
`+
FIXME: If we build macros for the builder, specify the path.
`
``
29
`+
self.cmake_options.define('SwiftTesting_MACRO', 'NO')
`
``
30
+
``
31
`+
- if host_target.startswith('android') and self.is_cross_compile_target(host_target):
`
``
32
`+
- host_config = HostSpecificConfiguration(host_target, self.args)
`
``
33
`+
- self.cmake_options.extend(host_config.cmake_options)
`
``
34
`+
- flags = '-target %s-unknown-linux-android%s ' % (self.args.android_arch,
`
``
35
`+
- self.args.android_api_level)
`
``
36
`+
`
``
37
`+
- flags += '-resource-dir %s/lib/swift ' % (
`
``
38
`+
- self.host_install_destdir(host_target) + self.args.install_prefix)
`
``
39
`+
`
``
40
`+
- ndk_path = StdlibDeploymentTarget.get_target_for_name(host_target).platform.ndk_toolchain_path(self.args)
`
``
41
`+
- flags += '-sdk %s/sysroot ' % (ndk_path)
`
``
42
`+
- flags += '-tools-directory %s/bin' % (ndk_path)
`
``
43
`+
- self.cmake_options.define('CMAKE_Swift_FLAGS', flags)
`
``
44
`+
- self.cmake_options.define('CMAKE_CXX_COMPILER_WORKS', 'True')
`
``
45
`+
- self.cmake_options.define('CMAKE_FIND_ROOT_PATH', self.args.cross_compile_deps_path)
`
``
46
`+
`
``
47
`+
self.generate_toolchain_file_for_darwin_or_linux(
`
``
48
`+
host_target, override_macos_deployment_version=override_deployment_version)
`
``
49
`+
self.build_with_cmake([], self.args.build_variant, [],
`
13
50
`diff --git a/swift-corelibs-foundation/Sources/Foundation/Process.swift b/swift-corelibs-foundation/Sources/Foundation/Process.swift
`
14
51
`index 758dd1df..02970992 100644
`
15
52
`--- a/swift-corelibs-foundation/Sources/Foundation/Process.swift
`
`@@ -39,3 +76,61 @@ index 758dd1df..02970992 100644
`
39
76
` #endif
`
40
77
` try _throwIfPosixError(posix_spawnattr_init(&spawnAttrs))
`
41
78
` try _throwIfPosixError(posix_spawnattr_setflags(&spawnAttrs, .init(POSIX_SPAWN_SETPGROUP)))
`
``
79
`+
diff --git a/swift-testing/CMakeLists.txt b/swift-testing/CMakeLists.txt
`
``
80
`+
index 1be9a4b..bd7b1bd 100644
`
``
81
`+
--- a/swift-testing/CMakeLists.txt
`
``
82
`+
+++ b/swift-testing/CMakeLists.txt
`
``
83
`+
@@ -28,6 +28,7 @@ list(APPEND CMAKE_MODULE_PATH
`
``
84
`+
${PROJECT_SOURCE_DIR}/cmake/modules
`
``
85
`+
${PROJECT_SOURCE_DIR}/cmake/modules/shared)
`
``
86
+
``
87
`+
+set(CMAKE_SHARED_LINKER_FLAGS "")
`
``
88
`+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
`
``
89
`+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
`
``
90
`+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
`
``
91
`+
diff --git a/swift-testing/Sources/Testing/CMakeLists.txt b/swift-testing/Sources/Testing/CMakeLists.tx
`
``
92
`+
index e40cb1b..ff2f920 100644
`
``
93
`+
--- a/swift-testing/Sources/Testing/CMakeLists.txt
`
``
94
`+
+++ b/swift-testing/Sources/Testing/CMakeLists.txt
`
``
95
`+
@@ -110,7 +110,10 @@ target_link_libraries(Testing PRIVATE
`
``
96
`+
if(NOT APPLE)
`
``
97
`+
if(NOT CMAKE_SYSTEM_NAME STREQUAL WASI)
`
``
98
`+
target_link_libraries(Testing PUBLIC
`
``
99
`+
- dispatch)
`
``
100
`+
- dispatch android-execinfo)
`
``
101
`+
- list(GET CMAKE_FIND_ROOT_PATH 0 BT_DIR)
`
``
102
`+
- target_include_directories(Testing PUBLIC ${BT_DIR}/usr/include)
`
``
103
`+
- target_link_directories(Testing PUBLIC ${BT_DIR}/usr/lib)
`
``
104
`+
endif()
`
``
105
`+
target_link_libraries(Testing PUBLIC
`
``
106
`+
Foundation)
`
``
107
`+
diff --git a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
`
``
108
`+
index 1553725..d9f9e5b 100644
`
``
109
`+
--- a/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
`
``
110
`+
+++ b/swift-testing/cmake/modules/SwiftModuleInstallation.cmake
`
``
111
`+
@@ -75,6 +75,10 @@ function(_swift_testing_install_target module)
`
``
112
`+
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
`
``
113
`+
if(CMAKE_Swift_COMPILER_TARGET)
`
``
114
`+
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
`
``
115
`+
- else()
`
``
116
`+
- set(arg_list ${CMAKE_Swift_FLAGS})
`
``
117
`+
- separate_arguments(arg_list)
`
``
118
`+
- list(APPEND module_triple_command ${arg_list})
`
``
119
`+
endif()
`
``
120
`+
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
`
``
121
`+
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
`
``
122
`+
diff --git a/swift-testing/cmake/modules/TargetTriple.cmake b/swift-testing/cmake/modules/TargetTriple.cmake
`
``
123
`+
index e087cc4..02f3a95 100644
`
``
124
`+
--- a/swift-testing/cmake/modules/TargetTriple.cmake
`
``
125
`+
+++ b/swift-testing/cmake/modules/TargetTriple.cmake
`
``
126
`+
@@ -10,6 +10,10 @@
`
``
127
`+
set(SWT_TARGET_INFO_COMMAND "${CMAKE_Swift_COMPILER}" -print-target-info)
`
``
128
`+
if(CMAKE_Swift_COMPILER_TARGET)
`
``
129
`+
list(APPEND SWT_TARGET_INFO_COMMAND -target ${CMAKE_Swift_COMPILER_TARGET})
`
``
130
`+
+else()
`
``
131
`+
- set(arg_list ${CMAKE_Swift_FLAGS})
`
``
132
`+
- separate_arguments(arg_list)
`
``
133
`+
- list(APPEND SWT_TARGET_INFO_COMMAND ${arg_list})
`
``
134
`+
endif()
`
``
135
`+
execute_process(COMMAND ${SWT_TARGET_INFO_COMMAND} OUTPUT_VARIABLE SWT_TARGET_INFO_JSON)
`
``
136
`+
string(JSON SWT_TARGET_TRIPLE GET "${SWT_TARGET_INFO_JSON}" "target" "unversionedTriple")
`