4个版本
0.2.3 | 2024年6月27日 |
---|---|
0.2.2 | 2024年6月26日 |
0.2.1 | 2024年6月24日 |
0.2.0 | 2024年6月24日 |
175 在 构建工具
每月 138 次下载
58KB
436 代码行
Cargo xcode-build-rs
100%使用Rust封装的iOS XCode构建脚本,来自bevy
示例。
使用Rust脚本而不是sh
脚本(或nu
shell)的优点
- 由于二进制文件使用
crates.io
分发,因此可以进行更新 - 允许全球协作,例如,我发现一个需要
sudo xcode-select --install
的情况,并且可以将此建议添加到错误消息中,供所有人受益 - 可以处理更复杂的逻辑,更容易使用库,例如,检查
cc
编译器是否在$PATH
- 使用人类可理解的日志记录一切(而不是
set -exu
)
安装
cargo install cargo-xcode-build-rs
这是我在XCode项目中使用它的方法,该项目是从bevy
移动示例中复制的: https://github.com/ActuallyHappening/YMap/blob/master/crates/cargo_xcode_build_rs/docs/xcode-usage.png
用法
在实际的xcode脚本中使用 cargo xcode-build-rs --manifest-dir . xcode
。使用 cargo xcode-build-rs --manifest-dir . --colour test
来开始一个测试iOS模拟器构建,通常情况下不需要这样做。
配置
为了编译启用特殊Cargo功能的iOS项目,请将一个 package.metadata.xcode-build-rs
部分添加到您的 Cargo.toml
文件中。例如
[package.metadata.xcode-build-rs.ios]
## As an example, when set to true enabled default features
## which is already the default.
## Set to false to disable default features
## See Cargo's docs: https://doc.rust-lang.net.cn/cargo/reference/features.html#dependency-features
default-features = true
## What features to enable
features = ["ios"]
## Extra flags to pass to `cargo rustc`
extra_flags = ["--cfg", "winit_ignore_noise_logs_unstable"]
帮助信息 cargo xcode-build-rs --help
Build script for XCode when compiling rust for iOS
Usage: cargo xcode-build-rs [OPTIONS] --manifest-dir <MANIFEST_DIR> <COMMAND>
Commands:
xcode Run in XCode
test Run a test build for an iOS simulator
help Print this message or the help of the given subcommand(s)
Options:
--colour By default, doesn't display colour because this can be annoying in the XCode terminal
--manifest-dir <MANIFEST_DIR> The --manifest-path option to pass to `cargo rustc builds`. Often you can pass `.`
-h, --help Print help
-V, --version Print version
致谢
基于bevy移动示例脚本 build_rust_deps.sh
这里。该脚本还基于mozilla脚本 这里
开发
git clone https://github.com/ActuallyHappening/YMap.git
cd crates/xcode_build_rs
cargo is
在您的系统上本地安装。使用 cargo rt
在您的系统上本地以测试模式运行CLI。
依赖关系
~12–23MB
~334K SLoC