Skip to content

Commit e98ec2c

Browse files
committed
Update readme
1 parent f5ff59f commit e98ec2c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ fn android() {
7878

7979
Add `-v` or `-vv` as you ordinarily would after the cargo command.
8080

81+
### Environment variable configuration
82+
83+
You can configure `cargo-ndk` using environment variables with the `CARGO_NDK_` prefix:
84+
85+
- `CARGO_NDK_TARGET`: Set default target(s) (comma-separated for multiple targets)
86+
- `CARGO_NDK_PLATFORM`: Set default API platform level
87+
- `CARGO_NDK_OUTPUT_DIR`: Set default output directory
88+
89+
These can be overridden by command-line arguments.
90+
8191
### Providing environment variables for C dependencies
8292

8393
`cargo-ndk` derives which environment variables to read the same way as the `cc` crate.
@@ -93,6 +103,8 @@ These environment variables are exported for use in build scripts and other down
93103
- `CARGO_NDK_SYSROOT_TARGET`: the target name for the files inside the sysroot (differs slightly from the standard LLVM triples)
94104
- `CARGO_NDK_SYSROOT_LIBS_PATH`: path to the libraries inside the sysroot with the given sysroot target (e.g. `$CARGO_NDK_SYSROOT_PATH/usr/lib/$CARGO_NDK_SYSROOT_TARGET`)
95105

106+
Environment variables for bindgen are automatically configured and exported as well.
107+
96108
### Printing the environment
97109

98110
Sometimes you just want the environment variables that `cargo-ndk` configures so you can, say, set up rust-analyzer in VS Code or similar.
@@ -119,6 +131,8 @@ For configuring rust-analyzer, add the `--json` flag and paste the blob into the
119131
- macOS (`x86_64` and `arm64`)
120132
- Windows
121133

134+
You can also build for Termux or similar by providing the environment variable `CARGO_NDK_ON_ANDROID` at build-time. Please note that this configuration is *not supported*.
135+
122136
## Local development
123137

124138
`git clone` and then install the crate with `cargo`:

0 commit comments

Comments
 (0)