@@ -161,6 +161,9 @@ public final class SwiftTool {
161
161
/// Path to the shared configuration directory
162
162
public let sharedConfigurationDirectory : AbsolutePath ?
163
163
164
+ /// Path to the cross-compilation SDK directory.
165
+ let sharedCCSDKDirectory : AbsolutePath ?
166
+
164
167
/// Cancellator to handle cancellation of outstanding work when handling SIGINT
165
168
public let cancellator : Cancellator
166
169
@@ -304,9 +307,10 @@ public final class SwiftTool {
304
307
( packageRoot ?? cwd) . appending ( component: " .build " )
305
308
306
309
// make sure common directories are created
307
- self . sharedSecurityDirectory = try getSharedSecurityDirectory ( options: self . options, fileSystem: fileSystem, observabilityScope: self . observabilityScope)
308
- self . sharedConfigurationDirectory = try getSharedConfigurationDirectory ( options: self . options, fileSystem: fileSystem, observabilityScope: self . observabilityScope)
309
- self . sharedCacheDirectory = try getSharedCacheDirectory ( options: self . options, fileSystem: fileSystem, observabilityScope: self . observabilityScope)
310
+ self . sharedSecurityDirectory = try getSharedSecurityDirectory ( options: self . options, fileSystem: fileSystem)
311
+ self . sharedConfigurationDirectory = try getSharedConfigurationDirectory ( options: self . options, fileSystem: fileSystem)
312
+ self . sharedCacheDirectory = try getSharedCacheDirectory ( options: self . options, fileSystem: fileSystem)
313
+ self . sharedCCSDKDirectory = try getSharedCCSDKsDirectory ( options: self . options, fileSystem: fileSystem)
310
314
311
315
// set global process logging handler
312
316
Process . loggingHandler = { self . observabilityScope. emit ( debug: $0) }
@@ -738,7 +742,7 @@ private func getEnvBuildPath(workingDir: AbsolutePath) throws -> AbsolutePath? {
738
742
}
739
743
740
744
741
- private func getSharedSecurityDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
745
+ private func getSharedSecurityDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
742
746
if let explicitSecurityDirectory = options. locations. securityDirectory {
743
747
// Create the explicit security path if necessary
744
748
if !fileSystem. exists ( explicitSecurityDirectory) {
@@ -751,7 +755,7 @@ private func getSharedSecurityDirectory(options: GlobalOptions, fileSystem: File
751
755
}
752
756
}
753
757
754
- private func getSharedConfigurationDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
758
+ private func getSharedConfigurationDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
755
759
if let explicitConfigurationDirectory = options. locations. configurationDirectory {
756
760
// Create the explicit config path if necessary
757
761
if !fileSystem. exists ( explicitConfigurationDirectory) {
@@ -764,7 +768,7 @@ private func getSharedConfigurationDirectory(options: GlobalOptions, fileSystem:
764
768
}
765
769
}
766
770
767
- private func getSharedCacheDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
771
+ private func getSharedCacheDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
768
772
if let explicitCacheDirectory = options. locations. cacheDirectory {
769
773
// Create the explicit cache path if necessary
770
774
if !fileSystem. exists ( explicitCacheDirectory) {
@@ -777,6 +781,21 @@ private func getSharedCacheDirectory(options: GlobalOptions, fileSystem: FileSys
777
781
}
778
782
}
779
783
784
+ private func getSharedCCSDKsDirectory(
785
+ options: GlobalOptions ,
786
+ fileSystem: FileSystem
787
+ ) throws -> AbsolutePath ? {
788
+ if let explicitCCSDKsDirectory = options. locations. ccSDKsDirectory {
789
+ // Create the explicit SDKs path if necessary
790
+ if !fileSystem. exists ( explicitCCSDKsDirectory) {
791
+ try fileSystem. createDirectory ( explicitCCSDKsDirectory, recursive: true )
792
+ }
793
+ return explicitCCSDKsDirectory
794
+ } else {
795
+ return try fileSystem. swiftPMCrossCompilationSDKsDirectory
796
+ }
797
+ }
798
+
780
799
extension Basics . Diagnostic {
781
800
static func unsupportedFlag( _ flag: String ) -> Self {
782
801
. warning( " \( flag) is an *unsupported* option which can be removed at any time; do not rely on it " )
0 commit comments