android_build/lib.rs
1//! Supports Android-specific Java build and run tasks in Rust projects from a Cargo build script.
2//!
3//! ## Tools exposed by this crate
4//! * javac: use the [`JavaBuild`] struct.
5//! * java: use the [`JavaRun`] struct.
6//! * d8: through the [`Dexer`] struct.
7//!
8//! ## Environment variables in use
9//! * `ANDROID_HOME` or `ANDROID_SDK_ROOT`: path to the Android SDK directory.
10//! * `ANDROID_BUILD_TOOLS_VERSION`: the version of the Android build tools.
11//! * Examples: `33.0.1`, `34.0.0-rc2`.
12//! * This must be fully specified all in one string.
13//! * `ANDROID_PLATFORM`, `ANDROID_API_LEVEL`, or `ANDROID_SDK_VERSION`:
14//! the platform version string (aka API level, SDK version) being targeted for compilation.
15//! * All three of these environment variables are treated identically.
16//! * Examples: `34`, `android-34`, `android-33`, `33`.
17//! * If an SDK extension must be specified, use the full string with the `android` prefix
18//! like so: `android-33-ext4`.
19//! * This may or may not include the SDK extension level as a suffix
20//! (see `ANDROID_SDK_EXTENSION` below).
21//! * `ANDROID_SDK_EXTENSION`: the extension of the Android SDK.
22//! * To specify `android-33-ext4`, this can be set to `-ext4`, `ext4`, or just `4`.
23//! All of these will be treated identically.
24//! * If `ANDROID_PLATFORM`/`ANDROID_API_LEVEL`/`ANDROID_SDK_VERSION`
25//! already includes an extension, then `ANDROID_SDK_EXTENSION` will be ignored.
26//! * `ANDROID_D8_JAR`: the path to the `d8.jar` file.
27//! * `ANDROID_JAR`: the path to the `android.jar` file.
28//! * `JAVA_HOME`: the Java SDK directory.
29//! * `JAVA_SOURCE_VERSION`: the Java version for source compatibility,
30//! which is passed to the `--source` javac option, e.g., `8` for Java 1.8, or `17` for Java 17.
31//! * `JAVA_TARGET_VERSION`: the Java version for target compatibility,
32//! which is passed to the `--target` javac option, e.g., `7` for Java 1.7, or `17` for Java 17.
33//!
34//! ## Acknowledgments
35//! This crate simplifies some code found in other crates:
36//! * [`dirs-sys`](https://github.com/dirs-dev/dirs-sys-rs/blob/c0fd66cb08f1f97ebf670914253a34bd42d284fb/src/lib.rs#L151)
37//! for the Windows-specific home directory lookup.
38//! * [`java-locator`](https://github.com/astonbitecode/java-locator/)
39//! for finding the Java home directory on macOS, Linux, and Windows.
40//! * [`jerk`](https://github.com/MaulingMonkey/jerk)
41//! for arguments that can be passed into `java` and `javac` commands.
42//! * [`i-slint-backend-android-activity`](https://docs.rs/crate/i-slint-backend-android-activity/1.9.1/source/build.rs)
43//! for parsing `javac` version and finding the latest platform and build tools versions in the Android SDK installation.
44
45
46mod java_build;
47mod java_run;
48mod env_paths;
49mod dexer;
50
51pub use java_build::*;
52pub use java_run::*;
53pub use env_paths::*;
54pub use dexer::*;