@@ -9,6 +9,12 @@ func hasEnvironmentVariable(_ name: String) -> Bool {
9
9
return ProcessInfo . processInfo. environment [ name] != nil
10
10
}
11
11
12
+ /// Use the `NonDarwinLogger` even if `os_log` can be imported.
13
+ ///
14
+ /// This is useful when running tests using `swift test` because xctest will not display the output from `os_log` on the
15
+ /// command line.
16
+ let forceNonDarwinLogger = hasEnvironmentVariable ( " SOURCEKITLSP_FORCE_NON_DARWIN_LOGGER " )
17
+
12
18
// When building the toolchain on the CI, don't add the CI's runpath for the
13
19
// final build before installing.
14
20
let installAction = hasEnvironmentVariable ( " SOURCEKIT_LSP_CI_INSTALL " )
@@ -19,11 +25,14 @@ let useLocalDependencies = hasEnvironmentVariable("SWIFTCI_USE_LOCAL_DEPS")
19
25
20
26
// MARK: - Compute custom build settings
21
27
22
- let sourcekitLSPLinkSettings : [ LinkerSetting ]
28
+ var sourcekitLSPLinkSettings : [ LinkerSetting ] = [ ]
23
29
if installAction {
24
- sourcekitLSPLinkSettings = [ . unsafeFlags( [ " -no-toolchain-stdlib-rpath " ] , . when( platforms: [ . linux, . android] ) ) ]
25
- } else {
26
- sourcekitLSPLinkSettings = [ ]
30
+ sourcekitLSPLinkSettings += [ . unsafeFlags( [ " -no-toolchain-stdlib-rpath " ] , . when( platforms: [ . linux, . android] ) ) ]
31
+ }
32
+
33
+ var lspLoggingSwiftSettings : [ SwiftSetting ] = [ ]
34
+ if forceNonDarwinLogger {
35
+ lspLoggingSwiftSettings += [ . define( " SOURCEKITLSP_FORCE_NON_DARWIN_LOGGER " ) ]
27
36
}
28
37
29
38
// MARK: - Build the package
@@ -135,7 +144,8 @@ let package = Package(
135
144
dependencies: [
136
145
. product( name: " Crypto " , package : " swift-crypto " )
137
146
] ,
138
- exclude: [ " CMakeLists.txt " ]
147
+ exclude: [ " CMakeLists.txt " ] ,
148
+ swiftSettings: lspLoggingSwiftSettings
139
149
) ,
140
150
141
151
. testTarget(
0 commit comments