File tree Expand file tree Collapse file tree 5 files changed +24
-10
lines changed
SwiftSDKGenerator/Generator
Tests/SwiftSDKGeneratorTests Expand file tree Collapse file tree 5 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ struct GeneratorCLI: AsyncParsableCommand {
36
36
artifactID: options. sdkName ?? recipe. defaultArtifactID,
37
37
isIncremental: options. incremental,
38
38
isVerbose: options. verbose,
39
+ includeHostToolchain: !options. noHostToolchain,
39
40
logger: logger
40
41
)
41
42
Original file line number Diff line number Diff line change @@ -42,8 +42,11 @@ public extension SwiftSDKGenerator {
42
42
httpClientType = OfflineHTTPClient . self
43
43
#endif
44
44
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)
47
50
}
48
51
49
52
try await self . createDirectoryIfNeeded ( at: pathsConfiguration. artifactsCachePath)
Original file line number Diff line number Diff line change @@ -26,17 +26,23 @@ extension SwiftSDKGenerator {
26
26
27
27
let toolsetJSONPath = pathsConfiguration. swiftSDKRootPath. appending ( " toolset.json " )
28
28
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
+ }
30
40
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 )
37
44
}
38
45
39
- var toolset = Toolset ( rootPath: relativeToolchainBinDir. string)
40
46
recipe. applyPlatformOptions ( toolset: & toolset, targetTriple: self . targetTriple)
41
47
try writeFile ( at: toolsetJSONPath, encoder. encode ( toolset) )
42
48
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ public actor SwiftSDKGenerator {
24
24
let isIncremental : Bool
25
25
let isVerbose : Bool
26
26
let engineCachePath : SQLite . Location
27
+ let includeHostToolchain : Bool
27
28
let logger : Logger
28
29
29
30
public init (
@@ -32,6 +33,7 @@ public actor SwiftSDKGenerator {
32
33
artifactID: String ,
33
34
isIncremental: Bool ,
34
35
isVerbose: Bool ,
36
+ includeHostToolchain: Bool ,
35
37
logger: Logger
36
38
) async throws {
37
39
logGenerationStep ( " Looking up configuration values... " )
@@ -56,6 +58,7 @@ public actor SwiftSDKGenerator {
56
58
self . isVerbose = isVerbose
57
59
58
60
self . engineCachePath = . path( self . pathsConfiguration. artifactsCachePath. appending ( " cache.db " ) )
61
+ self . includeHostToolchain = includeHostToolchain
59
62
self . logger = logger
60
63
}
61
64
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ final class ArchitectureMappingTests: XCTestCase {
67
67
// combinations of build and runtime architecture
68
68
isIncremental: false ,
69
69
isVerbose: false ,
70
+ includeHostToolchain: true ,
70
71
logger: Logger ( label: " org.swift.swift-sdk-generator " )
71
72
)
72
73
You can’t perform that action at this time.
0 commit comments