Update the tools to use swift-command-line-tools.

This commit is contained in:
Doug
2024-05-15 10:37:44 +01:00
committed by Doug
parent 5fe84f9c85
commit 8da1752493
11 changed files with 49 additions and 64 deletions
+9 -8
View File
@@ -1,4 +1,5 @@
import ArgumentParser
import CommandLineTools
import Foundation
import Yams
@@ -67,7 +68,7 @@ struct BuildSDK: ParsableCommand {
/// but only when the ``target`` option hasn't been supplied.
func checkRustupTargets() throws {
guard target.isEmpty, device == 0, simulator == 0 else { return }
guard let output = try Utilities.zsh("rustup show") else { throw Error.rustupOutputFailure }
guard let output = try Zsh.run(command: "rustup show") else { throw Error.rustupOutputFailure }
var requiredTargets = Target.allCases.reduce(into: [String: Bool]()) { partialResult, target in
partialResult[target.rawValue] = false
@@ -85,14 +86,14 @@ struct BuildSDK: ParsableCommand {
/// Clones the Rust SDK if a copy isn't found in the parent directory.
func cloneSDKIfNeeded() throws {
guard !FileManager.default.fileExists(atPath: Utilities.sdkDirectoryURL.path) else { return }
try Utilities.zsh("git clone https://github.com/matrix-org/matrix-rust-sdk", workingDirectoryURL: Utilities.parentDirectoryURL)
guard !FileManager.default.fileExists(atPath: URL.sdkDirectory.path) else { return }
try Zsh.run(command: "git clone https://github.com/matrix-org/matrix-rust-sdk", directory: .parentDirectory)
}
/// Checkout the specified branch of the SDK if supplied.
func checkoutBranchIfSupplied() throws {
guard let branch else { return }
try Utilities.zsh("git checkout \(branch)", workingDirectoryURL: Utilities.sdkDirectoryURL)
try Zsh.run(command: "git checkout \(branch)", directory: .sdkDirectory)
}
/// Build the Rust SDK as an XCFramework with the debug profile.
@@ -103,7 +104,7 @@ struct BuildSDK: ParsableCommand {
if device > 0 {
buildCommand.append(" --target \(Target.iOS.rawValue)")
} else if simulator > 0 {
let hostArchitecture = try Utilities.zsh("arch")
let hostArchitecture = try Zsh.run(command: "arch")
if hostArchitecture?.trimmingCharacters(in: .whitespacesAndNewlines) == "arm64" {
buildCommand.append(" --target \(Target.simulatorARM64.rawValue)")
} else {
@@ -112,18 +113,18 @@ struct BuildSDK: ParsableCommand {
} else if !target.isEmpty {
target.forEach { buildCommand.append(" --target \($0.rawValue)") }
}
try Utilities.zsh(buildCommand, workingDirectoryURL: Utilities.sdkDirectoryURL)
try Zsh.run(command: buildCommand, directory: .sdkDirectory)
}
/// Update the Xcode project to use the build of the SDK.
func updateXcodeProject() throws {
try updateProjectYAML()
try Utilities.zsh("xcodegen")
try Zsh.run(command: "xcodegen")
}
/// Update project.yml with the local path of the SDK.
func updateProjectYAML() throws {
let yamlURL = Utilities.projectDirectoryURL.appendingPathComponent("project.yml")
let yamlURL = URL.projectDirectory.appendingPathComponent("project.yml")
let yamlString = try String(contentsOf: yamlURL)
guard var projectConfig = try Yams.compose(yaml: yamlString) else { throw Error.failureParsingProjectYAML }