xtask/README.md
Build automation tasks for Spacedrive using the xtask pattern.
The xtask pattern is the idiomatic Rust way to handle project-specific build automation. Instead of using shell scripts, Makefiles, JavaScript, or external build tools, you write your build tasks as Rust code in a workspace member called xtask.
This approach is used by major Rust projects including:
cargo and rustupRun tasks using cargo xtask:
# Setup development environment (replaces pnpm prep)
cargo xtask setup
# Build iOS framework (device + simulator)
cargo xtask build-ios
# Or use the convenient alias:
cargo ios
test-coreSingle source of truth for core integration tests!
Runs all sd-core integration tests with progress tracking and result summary. This command is used by both CI and local development, ensuring consistency.
Usage:
cargo xtask test-core # Run with minimal output
cargo xtask test-core --verbose # Show full test output
Features:
All tests are defined in xtask/src/test_core.rs as the single source of truth.
Add or remove tests there and they automatically apply to both CI and local runs.
setupReplaces pnpm prep with a pure Rust implementation!
Sets up your development environment:
apps/.deps/.cargo/config.toml from the templateUsage:
cargo xtask setup
First time setup:
# Install Rust if you haven't already
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add iOS targets (macOS only, optional)
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
# Run setup
cargo xtask setup
# Build the CLI
cargo build
build-iosBuilds the sd-ios-core library for iOS (macOS only):
aarch64-apple-ios (physical devices)aarch64-apple-ios-sim (M1/M2 simulator)x86_64-apple-ios (Intel simulator)lipoOutput: apps/ios/sd-ios-core/sd_ios_core.xcframework/
The XCFramework structure looks like:
sd_ios_core.xcframework/
├── Info.plist # Top-level XCFramework metadata
├── ios-arm64/
│ ├── libsd_ios_core.a # Device library
│ └── Info.plist # Device metadata
└── ios-arm64-simulator/
├── libsd_ios_core.a # Universal simulator library (ARM64 + x86_64)
└── Info.plist # Simulator metadata
The xtask pattern works through Cargo's workspace and alias features. When you run:
cargo ios
Cargo:
.cargo/config.tomlcargo run --package xtask -- build-iosxtask binarybuild-ios as an argumentThe xtask binary is just a regular Rust program that uses std::process::Command to invoke cargo builds and file operations.
pnpm prep (JavaScript)Old way:
pnpm i # Install JS dependencies
pnpm prep # Run JavaScript setup script
New way:
cargo xtask setup # Pure Rust, no JS needed!
scripts/build_ios_xcframework.sh (Bash)Old way:
./scripts/build_ios_xcframework.sh
New way:
cargo ios # Convenient alias
# or
cargo xtask build-ios
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
lipo command)To add a new task:
src/main.rsmain() to call your function.cargo/config.tomlExample:
fn clean_ios() -> Result<()> {
// Clean iOS builds
todo!()
}
// In main():
match args[1].as_str() {
"build-ios" => build_ios()?,
"clean-ios" => clean_ios()?, // Add this
_ => { /* ... */ }
}