Skip to content

Commit 7145887

Browse files
Replace --ignore-if-missing with local file check (#184)
This fixes #181. Tested this locally by building SDKs. It works for building the SDK for armv7 using my build artifacts: ``` swift run swift-sdk-generator make-linux-sdk --swift-version 6.0.3-RELEASE --host x86_64-unknown-linux-gnu --target armv7-unknown-linux-gnueabihf --target-swift-package-path ~/Downloads/swift-6.0.3-RELEASE-ubuntu-jammy-armv7-install ``` And also building an SDK for aarch64 using official swift.org artifacts: ``` swift run swift-sdk-generator make-linux-sdk --swift-version 6.0.3-RELEASE --host x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu ```
1 parent 0aa5486 commit 7145887

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Copy.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import SystemPackage
14+
import Foundation
1415

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

112-
for (pathWithinPackage, pathWithinSwiftSDK, ignoreIfMissing) in [
113+
for (pathWithinPackage, pathWithinSwiftSDK, isOptional) in [
113114
("lib/swift", sdkDirPath.appending("usr/lib"), false),
114115
("lib/swift_static", sdkDirPath.appending("usr/lib"), false),
115116
("lib/clang", sdkDirPath.appending("usr/lib"), true),
116117
("include", sdkDirPath.appending("usr"), false),
117118
] {
118-
try await rsync(
119-
from: distributionPath.appending(pathWithinPackage),
120-
to: pathWithinSwiftSDK, ignoreIfMissing: ignoreIfMissing
121-
)
119+
let fromPath = distributionPath.appending(pathWithinPackage)
120+
121+
if isOptional && !doesFileExist(at: fromPath) {
122+
logger.debug("Optional package path ignored since it does not exist", metadata: ["packagePath": .string(fromPath.string)])
123+
continue
124+
}
125+
126+
try await rsync(from: fromPath, to: pathWithinSwiftSDK)
122127
}
123128
}
124129
}

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ public actor SwiftSDKGenerator {
158158
try Data(contentsOf: URL(fileURLWithPath: path.string))
159159
}
160160

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

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

0 commit comments

Comments
 (0)