Skip to content

Commit 08c8bee

Browse files
Merge remote-tracking branch 'xtremekforever/swiftlang#65-support-for-armhf' into swiftlang#65-support-building-armhf-sdks
2 parents 1a05422 + aca3ee0 commit 08c8bee

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct GeneratorCLI: AsyncParsableCommand {
3636
artifactID: options.sdkName ?? recipe.defaultArtifactID,
3737
isIncremental: options.incremental,
3838
isVerbose: options.verbose,
39+
includeHostToolchain: !options.noHostToolchain,
3940
logger: logger
4041
)
4142

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Entrypoint.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ public extension SwiftSDKGenerator {
4242
httpClientType = OfflineHTTPClient.self
4343
#endif
4444
try await httpClientType.with { client in
45-
if !self.isIncremental {
46-
try await self.removeRecursively(at: pathsConfiguration.toolchainDirPath)
45+
if self.includeHostToolchain {
46+
if !self.isIncremental {
47+
try await self.removeRecursively(at: pathsConfiguration.toolchainDirPath)
48+
}
49+
try await self.createDirectoryIfNeeded(at: pathsConfiguration.toolchainDirPath)
4750
}
4851

4952
try await self.createDirectoryIfNeeded(at: pathsConfiguration.artifactsCachePath)

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Metadata.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@ extension SwiftSDKGenerator {
2626

2727
let toolsetJSONPath = pathsConfiguration.swiftSDKRootPath.appending("toolset.json")
2828

29-
var relativeToolchainBinDir = pathsConfiguration.toolchainBinDirPath
29+
var toolset: Toolset
30+
if self.includeHostToolchain {
31+
var relativeToolchainBinDir = pathsConfiguration.toolchainBinDirPath
32+
33+
guard
34+
relativeToolchainBinDir.removePrefix(pathsConfiguration.swiftSDKRootPath)
35+
else {
36+
fatalError(
37+
"`toolchainBinDirPath` is at an unexpected location that prevents computing a relative path"
38+
)
39+
}
3040

31-
guard
32-
relativeToolchainBinDir.removePrefix(pathsConfiguration.swiftSDKRootPath)
33-
else {
34-
fatalError(
35-
"`toolchainBinDirPath` is at an unexpected location that prevents computing a relative path"
36-
)
41+
toolset = Toolset(rootPath: relativeToolchainBinDir.string)
42+
} else {
43+
toolset = Toolset(rootPath: nil)
3744
}
3845

39-
var toolset = Toolset(rootPath: relativeToolchainBinDir.string)
4046
recipe.applyPlatformOptions(toolset: &toolset, targetTriple: self.targetTriple)
4147
try writeFile(at: toolsetJSONPath, encoder.encode(toolset))
4248

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public actor SwiftSDKGenerator {
2424
let isIncremental: Bool
2525
let isVerbose: Bool
2626
let engineCachePath: SQLite.Location
27+
let includeHostToolchain: Bool
2728
let logger: Logger
2829

2930
public init(
@@ -32,6 +33,7 @@ public actor SwiftSDKGenerator {
3233
artifactID: String,
3334
isIncremental: Bool,
3435
isVerbose: Bool,
36+
includeHostToolchain: Bool,
3537
logger: Logger
3638
) async throws {
3739
logGenerationStep("Looking up configuration values...")
@@ -56,6 +58,7 @@ public actor SwiftSDKGenerator {
5658
self.isVerbose = isVerbose
5759

5860
self.engineCachePath = .path(self.pathsConfiguration.artifactsCachePath.appending("cache.db"))
61+
self.includeHostToolchain = includeHostToolchain
5962
self.logger = logger
6063
}
6164

Tests/SwiftSDKGeneratorTests/ArchitectureMappingTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ final class ArchitectureMappingTests: XCTestCase {
6767
// combinations of build and runtime architecture
6868
isIncremental: false,
6969
isVerbose: false,
70+
includeHostToolchain: true,
7071
logger: Logger(label: "org.swift.swift-sdk-generator")
7172
)
7273

0 commit comments

Comments
 (0)