File tree 9 files changed +84
-23
lines changed
9 files changed +84
-23
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ extension Array where Element == PackageDescription.CXXSetting {
170
170
} else {
171
171
git. currentCommit
172
172
}
173
- result. append ( . define( " _SWT_TESTING_LIBRARY_VERSION " , to: #"" \#( testingLibraryVersion) ""# ) )
173
+ result. append ( . define( " SWT_TESTING_LIBRARY_VERSION " , to: #"" \#( testingLibraryVersion) ""# ) )
174
174
}
175
175
176
176
return result
Original file line number Diff line number Diff line change @@ -310,6 +310,9 @@ extension Event.HumanReadableOutputRecorder {
310
310
comments. append ( " Swift Version: \( swiftStandardLibraryVersion) " )
311
311
}
312
312
comments. append ( " Testing Library Version: \( testingLibraryVersion) " )
313
+ if let targetTriple {
314
+ comments. append ( " Target Platform: \( targetTriple) " )
315
+ }
313
316
if verbosity > 0 {
314
317
#if targetEnvironment(simulator)
315
318
comments. append ( " OS Version (Simulator): \( simulatorVersion) " )
Original file line number Diff line number Diff line change @@ -128,6 +128,13 @@ var testingLibraryVersion: String {
128
128
swt_getTestingLibraryVersion ( ) . flatMap ( String . init ( validatingCString: ) ) ?? " unknown "
129
129
}
130
130
131
+ /// Get the LLVM target triple used to build the testing library, if available.
132
+ ///
133
+ /// This value is not part of the public interface of the testing library.
134
+ var targetTriple: String? {
135
+ swt_getTargetTriple ( ) . flatMap ( String . init ( validatingCString: ) )
136
+ }
137
+
131
138
/// A human-readable string describing the Swift Standard Library's version.
132
139
///
133
140
/// This value's format is platform-specific and is not meant to be
Original file line number Diff line number Diff line change 9
9
set (CMAKE_CXX_SCAN_FOR_MODULES 0)
10
10
11
11
include (LibraryVersion)
12
+ include (TargetTriple)
12
13
add_library (_TestingInternals STATIC
13
14
Discovery.cpp
14
15
Versions.cpp
Original file line number Diff line number Diff line change 10
10
11
11
#include " Versions.h"
12
12
13
- const char *swt_getTestingLibraryVersion (void ) {
14
13
#if defined(_SWT_TESTING_LIBRARY_VERSION)
15
- return _SWT_TESTING_LIBRARY_VERSION;
14
+ #warning _SWT_TESTING_LIBRARY_VERSION is deprecated
15
+ #warning Define SWT_TESTING_LIBRARY_VERSION and optionally SWT_TARGET_TRIPLE instead
16
+ #endif
17
+
18
+ const char *swt_getTestingLibraryVersion (void ) {
19
+ #if defined(SWT_TESTING_LIBRARY_VERSION)
20
+ return SWT_TESTING_LIBRARY_VERSION;
16
21
#else
17
- #warning _SWT_TESTING_LIBRARY_VERSION not defined: testing library version is unavailable
22
+ #warning SWT_TESTING_LIBRARY_VERSION not defined: testing library version is unavailable
18
23
return nullptr ;
19
24
#endif
20
25
}
26
+
27
+ const char *swt_getTargetTriple (void ) {
28
+ #if defined(SWT_TARGET_TRIPLE)
29
+ return SWT_TARGET_TRIPLE;
30
+ #else
31
+ // If we're here, we're presumably building as a package. Swift Package
32
+ // Manager does not provide a way to get the target triple from within the
33
+ // package manifest. SEE: swift-package-manager-#7929
34
+ //
35
+ // clang has __is_target_*() intrinsics, but we don't want to play a game of
36
+ // Twenty Questions in order to synthesize the triple (and still potentially
37
+ // get it wrong.) SEE: rdar://134933385
38
+ return nullptr ;
39
+ #endif
40
+ }
41
+
42
+ #if defined(__wasi__)
43
+ const char *swt_getWASIVersion (void ) {
44
+ #if defined(WASI_LIBC_VERSION)
45
+ return WASI_LIBC_VERSION;
46
+ #else
47
+ return nullptr ;
48
+ #endif
49
+ }
50
+ #endif
Original file line number Diff line number Diff line change @@ -121,24 +121,6 @@ static int swt_siginfo_t_si_status(const siginfo_t *siginfo) {
121
121
}
122
122
#endif
123
123
124
- #if defined(__wasi__ )
125
- /// Get the version of the C standard library and runtime used by WASI, if
126
- /// available.
127
- ///
128
- /// This function is provided because `WASI_LIBC_VERSION` may or may not be
129
- /// defined and may or may not be a complex macro.
130
- ///
131
- /// For more information about the `WASI_LIBC_VERSION` macro, see
132
- /// [wasi-libc-#490](https://github.com/WebAssembly/wasi-libc/issues/490).
133
- static const char * _Nullable swt_getWASIVersion (void ) {
134
- #if defined(WASI_LIBC_VERSION )
135
- return WASI_LIBC_VERSION ;
136
- #else
137
- return 0 ;
138
- #endif
139
- }
140
- #endif
141
-
142
124
SWT_ASSUME_NONNULL_END
143
125
144
126
#endif
Original file line number Diff line number Diff line change @@ -23,6 +23,22 @@ SWT_ASSUME_NONNULL_BEGIN
23
23
/// other conditions. Do not attempt to parse it.
24
24
SWT_EXTERN const char * _Nullable swt_getTestingLibraryVersion (void );
25
25
26
+ /// Get the LLVM target triple used to build the testing library.
27
+ ///
28
+ /// - Returns: A string containing the LLVM target triple used to build the
29
+ /// testing library, or `nullptr` if that information is not available.
30
+ SWT_EXTERN const char * _Nullable swt_getTargetTriple (void );
31
+
32
+ /// Get the version of the C standard library and runtime used by WASI, if
33
+ /// available.
34
+ ///
35
+ /// This function is provided because `WASI_LIBC_VERSION` may or may not be
36
+ /// defined and may or may not be a complex macro.
37
+ ///
38
+ /// For more information about the `WASI_LIBC_VERSION` macro, see
39
+ /// [wasi-libc-#490](https://github.com/WebAssembly/wasi-libc/issues/490).
40
+ SWT_EXTERN const char * _Nullable swt_getWASIVersion (void );
41
+
26
42
SWT_ASSUME_NONNULL_END
27
43
28
44
#endif
Original file line number Diff line number Diff line change @@ -40,4 +40,4 @@ endif()
40
40
# All done!
41
41
message (STATUS "Swift Testing version: ${SWT_TESTING_LIBRARY_VERSION} " )
42
42
add_compile_definitions (
43
- "$<$<COMPILE_LANGUAGE:CXX>:_SWT_TESTING_LIBRARY_VERSION =\" ${SWT_TESTING_LIBRARY_VERSION} \" >" )
43
+ "$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_VERSION =\" ${SWT_TESTING_LIBRARY_VERSION} \" >" )
Original file line number Diff line number Diff line change
1
+ # This source file is part of the Swift.org open source project
2
+ #
3
+ # Copyright (c) 2024 Apple Inc. and the Swift project authors
4
+ # Licensed under Apache License v2.0 with Runtime Library Exception
5
+ #
6
+ # See http://swift.org/LICENSE.txt for license information
7
+ # See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8
+
9
+ # Ask the Swift compiler what target triple it will be compiling with today.
10
+ set (SWT_TARGET_INFO_COMMAND "${CMAKE_Swift_COMPILER} " -print-target -info)
11
+ if (CMAKE_Swift_COMPILER_TARGET)
12
+ list (APPEND SWT_TARGET_INFO_COMMAND -target ${CMAKE_Swift_COMPILER_TARGET} )
13
+ endif ()
14
+ execute_process (COMMAND ${SWT_TARGET_INFO_COMMAND} OUTPUT_VARIABLE SWT_TARGET_INFO_JSON)
15
+ string (JSON SWT_TARGET_TRIPLE GET "${SWT_TARGET_INFO_JSON} " "target" "unversionedTriple" )
16
+
17
+ # All done!
18
+ message (STATUS "Swift Testing target triple: ${SWT_TARGET_TRIPLE} " )
19
+ if (SWT_TARGET_TRIPLE)
20
+ add_compile_definitions (
21
+ "$<$<COMPILE_LANGUAGE:CXX>:SWT_TARGET_TRIPLE=\" ${SWT_TARGET_TRIPLE} \" >" )
22
+ endif ()
You can’t perform that action at this time.
0 commit comments