Skip to content

Commit 40dcb7c

Browse files
committed
Expand Linux checks to include Android or remove Linux checks
Anywhere we were checking for a Linux host, include Android as well if appropriate. Also adjust a couple other places to be non-Linux-specific where appropriate
1 parent 5ef6746 commit 40dcb7c

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

Sources/SWBCore/Core.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ struct CoreRegistryDelegate : PlatformRegistryDelegate, SDKRegistryDelegate, Spe
684684

685685
extension OperatingSystem {
686686
/// Whether the Core is allowed to create a fallback toolchain, SDK, and platform for this operating system in cases where no others have been provided.
687-
internal var createFallbackSystemToolchain: Bool {
687+
@_spi(Testing) public var createFallbackSystemToolchain: Bool {
688688
return self == .linux
689689
}
690690
}

Sources/SWBCore/Settings/Settings.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5282,7 +5282,7 @@ extension Settings {
52825282
}
52835283

52845284
extension OperatingSystem {
5285-
var xcodePlatformName: String {
5285+
@_spi(Testing) public var xcodePlatformName: String {
52865286
get throws {
52875287
switch self {
52885288
case .macOS:

Sources/SWBCore/WorkspaceContext.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public final class WorkspaceContext: Sendable {
384384

385385
extension FSProxy {
386386
private static var CreatedByBuildSystemAttribute: String {
387-
#if os(Linux)
387+
#if os(Linux) || os(Android)
388388
// On Linux, "the name [of an extended attribute] must be a null-terminated string prefixed by a namespace identifier and a dot character" and only the "user" namespace is available for unrestricted access.
389389
"user.org.swift.swift-build.CreatedByBuildSystem"
390390
#else

Tests/SWBCoreTests/PlatformRegistryTests.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ import SWBMacro
8181
@Test
8282
func loadingErrors() async throws {
8383
let builtinPlatforms: [String]
84-
#if os(Linux)
85-
builtinPlatforms = ["linux"]
86-
#else
87-
builtinPlatforms = []
88-
#endif
84+
let hostOS = try ProcessInfo.processInfo.hostOperatingSystem()
85+
if hostOS.createFallbackSystemToolchain {
86+
builtinPlatforms = try [hostOS.xcodePlatformName]
87+
} else {
88+
builtinPlatforms = []
89+
}
8990

9091
try await withRegistryForTestInputs([
9192
("unused", nil),

Tests/SWBLLBuildTests/LLBuildTests.swift

+2-5
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ fileprivate class LoggingDelegate: BuildSystemDelegate {
589589
}
590590

591591
@Test(.requireLLBuild(apiVersion: 15)) func commandSkipping() throws {
592-
#if os(Linux) && !DEBUG
593-
return // fails on Linux in release mode
594-
#endif
595-
596592
let fs = PseudoFS()
597593

598594
// Write the test manifest.
@@ -616,7 +612,8 @@ fileprivate class LoggingDelegate: BuildSystemDelegate {
616612
// Configure the delegate
617613
class Delegate: LoggingDelegate {
618614
override func shouldCommandStart(_ command: Command) -> Bool {
619-
assert(super.shouldCommandStart(command))
615+
let shouldStart = super.shouldCommandStart(command)
616+
#expect(shouldStart)
620617
return false
621618
}
622619
}

Tests/SwiftBuildTests/ConsoleCommands/CLIConnection.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public struct AsyncCLIConnectionResponseSequence<Base: AsyncSequence>: AsyncSequ
247247
} catch let error as SWBUtil.POSIXError {
248248
// The result of a read operation when pty session is closed is platform-dependent.
249249
// BSDs send EOF, Linux raises EIO...
250-
#if os(Linux)
250+
#if os(Linux) || os(Android)
251251
if error.code == EIO {
252252
break
253253
}
@@ -276,7 +276,7 @@ public struct AsyncCLIConnectionResponseSequence<Base: AsyncSequence>: AsyncSequ
276276
} catch let error as SWBUtil.POSIXError {
277277
// The result of a read operation when pty session is closed is platform-dependent.
278278
// BSDs send EOF, Linux raises EIO...
279-
#if os(Linux)
279+
#if os(Linux) || os(Android)
280280
if error.code == EIO {
281281
break
282282
}

0 commit comments

Comments
 (0)