@@ -161,6 +161,9 @@ public final class SwiftTool {
161161 /// Path to the shared configuration directory
162162 public let sharedConfigurationDirectory : AbsolutePath ?
163163
164+ /// Path to the cross-compilation SDK directory.
165+ let sharedCCSDKDirectory : AbsolutePath ?
166+
164167 /// Cancellator to handle cancellation of outstanding work when handling SIGINT
165168 public let cancellator : Cancellator
166169
@@ -304,9 +307,10 @@ public final class SwiftTool {
304307 ( packageRoot ?? cwd) . appending ( component: " .build " )
305308
306309 // 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)
310314
311315 // set global process logging handler
312316 Process . loggingHandler = { self . observabilityScope. emit ( debug: $0) }
@@ -738,7 +742,7 @@ private func getEnvBuildPath(workingDir: AbsolutePath) throws -> AbsolutePath? {
738742}
739743
740744
741- private func getSharedSecurityDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
745+ private func getSharedSecurityDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
742746 if let explicitSecurityDirectory = options. locations. securityDirectory {
743747 // Create the explicit security path if necessary
744748 if !fileSystem. exists ( explicitSecurityDirectory) {
@@ -751,7 +755,7 @@ private func getSharedSecurityDirectory(options: GlobalOptions, fileSystem: File
751755 }
752756}
753757
754- private func getSharedConfigurationDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
758+ private func getSharedConfigurationDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
755759 if let explicitConfigurationDirectory = options. locations. configurationDirectory {
756760 // Create the explicit config path if necessary
757761 if !fileSystem. exists ( explicitConfigurationDirectory) {
@@ -764,7 +768,7 @@ private func getSharedConfigurationDirectory(options: GlobalOptions, fileSystem:
764768 }
765769}
766770
767- private func getSharedCacheDirectory( options: GlobalOptions , fileSystem: FileSystem , observabilityScope : ObservabilityScope ) throws -> AbsolutePath ? {
771+ private func getSharedCacheDirectory( options: GlobalOptions , fileSystem: FileSystem ) throws -> AbsolutePath ? {
768772 if let explicitCacheDirectory = options. locations. cacheDirectory {
769773 // Create the explicit cache path if necessary
770774 if !fileSystem. exists ( explicitCacheDirectory) {
@@ -777,6 +781,21 @@ private func getSharedCacheDirectory(options: GlobalOptions, fileSystem: FileSys
777781 }
778782}
779783
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+
780799extension Basics . Diagnostic {
781800 static func unsupportedFlag( _ flag: String ) -> Self {
782801 . warning( " \( flag) is an *unsupported* option which can be removed at any time; do not rely on it " )
0 commit comments