Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an environment variable to keep the temp dir #67

Merged
merged 1 commit into from Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -49,6 +49,7 @@ panic_immediate_abort = false
In addition to the above configuration keys, `cargo-xbuild` can be also configured through the following environment variables:

- 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.
- 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.

## Dev channel

Expand Down
12 changes: 10 additions & 2 deletions src/sysroot.rs
Expand Up @@ -62,8 +62,16 @@ fn build_crate(
dst: &Path,
verbose: bool,
) -> Result<()> {
let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?;
let td = td.path();
let td = TempDir::new("cargo-xbuild").chain_err(|| "couldn't create a temporary directory")?;
let td_path;
let td = if env::var_os("XBUILD_KEEP_TEMP").is_some() {
td_path = td.into_path();
println!("XBUILD_KEEP_TEMP: files at {:?}", td_path);
&td_path
} else {
td.path()
};

let target_dir = td.join("target");

if let Some(profile) = ctoml.profile() {
Expand Down