Skip to content

Commit c8af5a3

Browse files
committed
Add an environment variable to keep the temp dir
1 parent 3f52f0e commit c8af5a3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ panic_immediate_abort = false
4949
In addition to the above configuration keys, `cargo-xbuild` can be also configured through the following environment variables:
5050

5151
- The `XBUILD_SYSROOT_PATH` variable can be used to specify where `cargo-xbuild` should place the generated sysroot. This variables takes precendence over the `package.metadata.cargo-xbuild.sysroot_path` configuration key.
52+
- When the `XBUILD_KEEP_TEMP` variable is set, the temporary directory used for compiling the sysroot is not deleted. This is useful for debugging. For convenience, `cargo-xbuild` also prints the directory name when the environment variable is set.
5253

5354
## Dev channel
5455

src/sysroot.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ fn build_crate(
6262
dst: &Path,
6363
verbose: bool,
6464
) -> Result<()> {
65-
let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?;
66-
let td = td.path();
65+
let td = TempDir::new("cargo-xbuild").chain_err(|| "couldn't create a temporary directory")?;
66+
let td_path;
67+
let td = if env::var_os("XBUILD_KEEP_TEMP").is_some() {
68+
td_path = td.into_path();
69+
println!("XBUILD_KEEP_TEMP: files at {:?}", td_path);
70+
&td_path
71+
} else {
72+
td.path()
73+
};
74+
6775
let target_dir = td.join("target");
6876

6977
if let Some(profile) = ctoml.profile() {

0 commit comments

Comments
 (0)