File tree Expand file tree Collapse file tree 9 files changed +84
-23
lines changed Expand file tree Collapse file tree 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 {
170170 } else {
171171 git. currentCommit
172172 }
173- result. append ( . define( " _SWT_TESTING_LIBRARY_VERSION " , to: #"" \#( testingLibraryVersion) ""# ) )
173+ result. append ( . define( " SWT_TESTING_LIBRARY_VERSION " , to: #"" \#( testingLibraryVersion) ""# ) )
174174 }
175175
176176 return result
Original file line number Diff line number Diff line change @@ -310,6 +310,9 @@ extension Event.HumanReadableOutputRecorder {
310310 comments. append ( " Swift Version: \( swiftStandardLibraryVersion) " )
311311 }
312312 comments. append ( " Testing Library Version: \( testingLibraryVersion) " )
313+ if let targetTriple {
314+ comments. append ( " Target Platform: \( targetTriple) " )
315+ }
313316 if verbosity > 0 {
314317#if targetEnvironment(simulator)
315318 comments. append ( " OS Version (Simulator): \( simulatorVersion) " )
Original file line number Diff line number Diff line change @@ -132,6 +132,13 @@ var testingLibraryVersion: String {
132132 swt_getTestingLibraryVersion ( ) . flatMap ( String . init ( validatingCString: ) ) ?? " unknown "
133133}
134134
135+ /// Get the LLVM target triple used to build the testing library, if available.
136+ ///
137+ /// This value is not part of the public interface of the testing library.
138+ var targetTriple: String? {
139+ swt_getTargetTriple ( ) . flatMap ( String . init ( validatingCString: ) )
140+ }
141+
135142/// A human-readable string describing the Swift Standard Library's version.
136143///
137144/// This value's format is platform-specific and is not meant to be
Original file line number Diff line number Diff line change 99set (CMAKE_CXX_SCAN_FOR_MODULES 0)
1010
1111include (LibraryVersion)
12+ include (TargetTriple)
1213add_library (_TestingInternals STATIC
1314 Discovery.cpp
1415 Versions.cpp
Original file line number Diff line number Diff line change 1010
1111#include " Versions.h"
1212
13- const char *swt_getTestingLibraryVersion (void ) {
1413#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;
1621#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
1823 return nullptr ;
1924#endif
2025}
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 @@ -134,24 +134,6 @@ static int swt_siginfo_t_si_status(const siginfo_t *siginfo) {
134134#endif
135135#endif
136136
137- #if defined(__wasi__ )
138- /// Get the version of the C standard library and runtime used by WASI, if
139- /// available.
140- ///
141- /// This function is provided because `WASI_LIBC_VERSION` may or may not be
142- /// defined and may or may not be a complex macro.
143- ///
144- /// For more information about the `WASI_LIBC_VERSION` macro, see
145- /// [wasi-libc-#490](https://github.com/WebAssembly/wasi-libc/issues/490).
146- static const char * _Nullable swt_getWASIVersion (void ) {
147- #if defined(WASI_LIBC_VERSION )
148- return WASI_LIBC_VERSION ;
149- #else
150- return 0 ;
151- #endif
152- }
153- #endif
154-
155137SWT_ASSUME_NONNULL_END
156138
157139#endif
Original file line number Diff line number Diff line change @@ -23,6 +23,22 @@ SWT_ASSUME_NONNULL_BEGIN
2323/// other conditions. Do not attempt to parse it.
2424SWT_EXTERN const char * _Nullable swt_getTestingLibraryVersion (void );
2525
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+
2642SWT_ASSUME_NONNULL_END
2743
2844#endif
Original file line number Diff line number Diff line change @@ -40,4 +40,4 @@ endif()
4040# All done!
4141message (STATUS "Swift Testing version: ${SWT_TESTING_LIBRARY_VERSION} " )
4242add_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