Skip to content

Commit 0c69592

Browse files
committed
docs(trim-paths): env CARGO_TRIM_PATHS for build scripts
1 parent aba839c commit 0c69592

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/doc/src/reference/unstable.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ For the latest nightly, see the [nightly version] of this page.
9494
* [per-package-target](#per-package-target) --- Sets the `--target` to use for each individual package.
9595
* [artifact dependencies](#artifact-dependencies) --- Allow build artifacts to be included into other build artifacts and build them for different targets.
9696
* [Edition 2024](#edition-2024) — Adds support for the 2024 Edition.
97-
* [Profile `trim-paths` option](#profile-trim-paths-option) --- Control the sanitisation of file paths in build outputs.
97+
* [Profile `trim-paths` option](#profile-trim-paths-option) --- Control the sanitization of file paths in build outputs.
9898
* Information and metadata
9999
* [Build-plan](#build-plan) --- Emits JSON information on which commands will be run.
100100
* [unit-graph](#unit-graph) --- Emits JSON for Cargo's internal graph structure.
@@ -1292,7 +1292,7 @@ edition that may break your build.
12921292
* Tracking Issue: [rust-lang/cargo#12137](https://github.com/rust-lang/cargo/issues/12137)
12931293
* Tracking Rustc Issue: [rust-lang/rust#111540](https://github.com/rust-lang/rust/issues/111540)
12941294

1295-
This adds a new profile setting to control how paths are sanitised in the resulting binary.
1295+
This adds a new profile setting to control how paths are sanitized in the resulting binary.
12961296
This can be enabled like so:
12971297

12981298
```toml
@@ -1370,6 +1370,19 @@ Paths to all other source files will not be affected.
13701370

13711371
This will not affect any hard-coded paths in the source code, such as in strings.
13721372

1373+
#### Environment variable
1374+
1375+
*as a new entry of ["Environment variables Cargo sets for build scripts"](./environment-variables.md#environment-variables-cargo-sets-for-crates)*
1376+
1377+
* `CARGO_TRIM_PATHS` --- The value of `trim-paths` profile option.
1378+
`false`, `"none"`, and empty arrays would be converted to `none`.
1379+
`true` and `"all"` become `all`.
1380+
Values in a non-empty array would be joined into a comma-separated list.
1381+
If the build script introduces absolute paths to built artifacts (such as by invoking a compiler),
1382+
the user may request them to be sanitized in different types of artifacts.
1383+
Common paths requiring sanitization include `OUT_DIR` and `CARGO_MANIFEST_DIR`,
1384+
plus any other introduced by the build script, such as include directories.
1385+
13731386
# Stabilized and removed features
13741387

13751388
## Compile progress

0 commit comments

Comments
 (0)