Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

import SystemPackage
import Foundation

extension SwiftSDKGenerator {
func copyTargetSwiftFromDocker(
Expand Down Expand Up @@ -109,16 +110,20 @@ extension SwiftSDKGenerator {
func copyTargetSwift(from distributionPath: FilePath, sdkDirPath: FilePath) async throws {
logger.info("Copying Swift core libraries for the target triple into Swift SDK bundle...")

for (pathWithinPackage, pathWithinSwiftSDK, ignoreIfMissing) in [
for (pathWithinPackage, pathWithinSwiftSDK, isOptional) in [
("lib/swift", sdkDirPath.appending("usr/lib"), false),
("lib/swift_static", sdkDirPath.appending("usr/lib"), false),
("lib/clang", sdkDirPath.appending("usr/lib"), true),
("include", sdkDirPath.appending("usr"), false),
] {
try await rsync(
from: distributionPath.appending(pathWithinPackage),
to: pathWithinSwiftSDK, ignoreIfMissing: ignoreIfMissing
)
let fromPath = distributionPath.appending(pathWithinPackage)

if isOptional && !doesFileExist(at: fromPath) {
logger.debug("Optional package path ignored since it does not exist", metadata: ["packagePath": .string(fromPath.string)])
continue
}

try await rsync(from: fromPath, to: pathWithinSwiftSDK)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,9 @@ public actor SwiftSDKGenerator {
try Data(contentsOf: URL(fileURLWithPath: path.string))
}

func rsync(from source: FilePath, to destination: FilePath, ignoreIfMissing: Bool = false) async throws {
func rsync(from source: FilePath, to destination: FilePath) async throws {
try self.createDirectoryIfNeeded(at: destination)
let ignoreMissingArgs = ignoreIfMissing ? "--ignore-missing-args" : ""
try await Shell.run("rsync -a \(ignoreMissingArgs) \(source) \(destination)", shouldLogCommands: self.isVerbose)
try await Shell.run("rsync -a \(source) \(destination)", shouldLogCommands: self.isVerbose)
}

func rsyncContents(from source: FilePath, to destination: FilePath) async throws {
Expand Down