Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace --ignore-if-missing with local file check #184

Merged
merged 4 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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, optional) 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 optional && !FileManager.default.fileExists(atPath: fromPath.string) {
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