mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Update build-sdk tool. (#2835)
- Support new --target option on Rust allowing multiple targets to be built. - Add new --device and --simulator shortcuts.
This commit is contained in:
parent
b7d492c206
commit
11b683601b
@ -21,8 +21,14 @@ struct BuildSDK: ParsableCommand {
|
|||||||
@Argument(help: "An optional argument to specify a branch of the SDK.")
|
@Argument(help: "An optional argument to specify a branch of the SDK.")
|
||||||
var branch: String?
|
var branch: String?
|
||||||
|
|
||||||
|
@Flag(help: "Build the SDK to run on an iPhone or iPad. This flag takes precedence over --simulator and --target.")
|
||||||
|
var device
|
||||||
|
|
||||||
|
@Flag(help: "Build the SDK to run on the simulator. This flag takes precedence over --target.")
|
||||||
|
var simulator
|
||||||
|
|
||||||
@Option(help: "The target to build for such as aarch64-apple-ios. Omit this option to build for all targets.")
|
@Option(help: "The target to build for such as aarch64-apple-ios. Omit this option to build for all targets.")
|
||||||
var target: Target?
|
var target: [Target]
|
||||||
|
|
||||||
@Option(help: "The profile to use when building the SDK. Omit this option to build in debug mode.")
|
@Option(help: "The profile to use when building the SDK. Omit this option to build in debug mode.")
|
||||||
var profile: Profile = .reldbg
|
var profile: Profile = .reldbg
|
||||||
@ -60,7 +66,7 @@ struct BuildSDK: ParsableCommand {
|
|||||||
/// Checks that all of the required targets have been added through rustup
|
/// Checks that all of the required targets have been added through rustup
|
||||||
/// but only when the ``target`` option hasn't been supplied.
|
/// but only when the ``target`` option hasn't been supplied.
|
||||||
func checkRustupTargets() throws {
|
func checkRustupTargets() throws {
|
||||||
guard target == nil else { return }
|
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 Utilities.zsh("rustup show") else { throw Error.rustupOutputFailure }
|
||||||
|
|
||||||
var requiredTargets = Target.allCases.reduce(into: [String: Bool]()) { partialResult, target in
|
var requiredTargets = Target.allCases.reduce(into: [String: Bool]()) { partialResult, target in
|
||||||
@ -94,8 +100,17 @@ struct BuildSDK: ParsableCommand {
|
|||||||
// unset fixes an issue where swift compilation prevents building for targets other than macOS X
|
// unset fixes an issue where swift compilation prevents building for targets other than macOS X
|
||||||
var buildCommand = "unset SDKROOT && cargo xtask swift build-framework"
|
var buildCommand = "unset SDKROOT && cargo xtask swift build-framework"
|
||||||
buildCommand.append(" --profile \(profile.rawValue)")
|
buildCommand.append(" --profile \(profile.rawValue)")
|
||||||
if let target {
|
if device > 0 {
|
||||||
buildCommand.append(" --only-target \(target.rawValue)")
|
buildCommand.append(" --target \(Target.iOS.rawValue)")
|
||||||
|
} else if simulator > 0 {
|
||||||
|
let hostArchitecture = try Utilities.zsh("arch")
|
||||||
|
if hostArchitecture?.trimmingCharacters(in: .whitespacesAndNewlines) == "arm64" {
|
||||||
|
buildCommand.append(" --target \(Target.simulatorARM64.rawValue)")
|
||||||
|
} else {
|
||||||
|
buildCommand.append(" --target \(Target.simulatorIntel.rawValue)")
|
||||||
|
}
|
||||||
|
} else if !target.isEmpty {
|
||||||
|
target.forEach { buildCommand.append(" --target \($0.rawValue)") }
|
||||||
}
|
}
|
||||||
try Utilities.zsh(buildCommand, workingDirectoryURL: Utilities.sdkDirectoryURL)
|
try Utilities.zsh(buildCommand, workingDirectoryURL: Utilities.sdkDirectoryURL)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user