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 support for CROSS_CONFIG environment var #597

Merged
merged 1 commit into from
Jan 25, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ $ cross rustc --target powerpc-unknown-linux-gnu --release -- -C lto

## Configuration

You can place a `Cross.toml` file in the root of your Cargo project to tweak
`cross`'s behavior:
You can place a `Cross.toml` file in the root of your Cargo project or use a
`CROSS_CONFIG` environment variable to tweak `cross`'s behavior:

### Custom Docker images

Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod rustc;
mod rustup;

use std::io::Write;
use std::path::PathBuf;
use std::process::ExitStatus;
use std::{env, io, process};

Expand Down Expand Up @@ -525,9 +526,13 @@ impl Toml {
}
}

/// Parses the `Cross.toml` at the root of the Cargo project (if any)
/// Parses the `Cross.toml` at the root of the Cargo project or from the
/// `CROSS_CONFIG` environment variable (if any exist in either location).
fn toml(root: &Root) -> Result<Option<Toml>> {
let path = root.path().join("Cross.toml");
let path = match env::var("CROSS_CONFIG") {
Ok(var) => PathBuf::from(var),
Err(_) => root.path().join("Cross.toml")
};

if path.exists() {
Ok(Some(Toml {
Expand Down