Skip to content

Commit

Permalink
Merge cross-rs#597
Browse files Browse the repository at this point in the history
597: Add support for `CROSS_CONFIG` environment var r=Emilgardis a=UebelAndre

This allows for the use of a `CROSS_CONFIG` environment variable to explicitly set the path to a `Cross.toml` file to use for builds.

Co-authored-by: UebelAndre <[email protected]>
  • Loading branch information
bors[bot] and UebelAndre authored Jan 25, 2022
2 parents 4b20973 + 1036e74 commit 95739b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 95739b6

Please sign in to comment.