You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,16 @@ fn android() {
78
78
79
79
Add `-v` or `-vv` as you ordinarily would after the cargo command.
80
80
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
+
81
91
### Providing environment variables for C dependencies
82
92
83
93
`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
93
103
-`CARGO_NDK_SYSROOT_TARGET`: the target name for the files inside the sysroot (differs slightly from the standard LLVM triples)
94
104
-`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`)
95
105
106
+
Environment variables for bindgen are automatically configured and exported as well.
107
+
96
108
### Printing the environment
97
109
98
110
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
119
131
- macOS (`x86_64` and `arm64`)
120
132
- Windows
121
133
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
+
122
136
## Local development
123
137
124
138
`git clone` and then install the crate with `cargo`:
0 commit comments