mobench_sdk/builders/mod.rs
1//! Build automation for mobile platforms.
2//!
3//! This module provides builders for Android and iOS that automate the process
4//! of compiling Rust code to mobile libraries and packaging them into mobile apps.
5//!
6//! ## Overview
7//!
8//! The builders handle the complete build pipeline:
9//!
10//! 1. **Rust compilation** - Cross-compile Rust to mobile targets
11//! 2. **Binding generation** - Generate UniFFI Kotlin/Swift bindings
12//! 3. **Native library packaging** - Copy `.so` files to Android or create xcframework for iOS
13//! 4. **App building** - Run Gradle (Android) or xcodebuild (iOS)
14//!
15//! ## Builders
16//!
17//! | Builder | Platform | Output |
18//! |---------|----------|--------|
19//! | [`AndroidBuilder`] | Android | APK with native `.so` libraries |
20//! | [`IosBuilder`] | iOS | xcframework with static libraries |
21//!
22//! ## Common Utilities
23//!
24//! The `common` module (internal) provides shared functionality:
25//!
26//! - Workspace-aware Cargo target directory detection
27//! - Host library path resolution for UniFFI binding generation
28//! - Consistent command execution with actionable error messages
29//!
30//! ## Builder Options
31//!
32//! Both builders support the following configuration:
33//!
34//! - **`verbose(bool)`** - Enable detailed output showing each build step
35//! - **`dry_run(bool)`** - Preview build steps without making changes
36//! - **`output_dir(path)`** - Customize output location (default: `target/mobench/`)
37//! - **`crate_dir(path)`** - Override auto-detected crate location
38//!
39//! ## Example
40//!
41//! ```ignore
42//! use mobench_sdk::builders::{AndroidBuilder, IosBuilder};
43//! use mobench_sdk::{BuildConfig, BuildProfile, Target};
44//!
45//! // Build for Android with dry-run
46//! let android = AndroidBuilder::new(".", "my-bench")
47//! .verbose(true)
48//! .dry_run(true); // Preview only
49//!
50//! // Build for iOS
51//! let ios = IosBuilder::new(".", "my-bench")
52//! .verbose(true);
53//!
54//! let config = BuildConfig {
55//! target: Target::Android,
56//! profile: BuildProfile::Release,
57//! incremental: true,
58//! };
59//!
60//! android.build(&config)?;
61//! # Ok::<(), mobench_sdk::BenchError>(())
62//! ```
63
64pub mod android;
65pub mod common;
66pub mod ios;
67
68// Re-export builders
69pub use android::AndroidBuilder;
70pub use common::{
71 BenchMeta, EmbeddedBenchSpec, create_bench_meta, embed_bench_meta, embed_bench_spec,
72};
73pub use ios::{IosBuilder, SigningMethod};