Skip to content

Commit

Permalink
support .cargo/config.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
benmkw committed Aug 22, 2020
1 parent 6f7e79e commit 85d1924
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,22 @@ impl Project {
// parse Cargo.toml
let toml = root.join("Cargo.toml");
let cargo_config = Path::new(".cargo").join("config");
let cargo_config_toml = Path::new(".cargo").join("config.toml");
let manifest = parse::<Manifest>(&toml)?;

// parse .cargo/config
// parse .cargo/config or .cargo/config.toml
let mut target = None;
let mut target_dir = env::var_os("CARGO_TARGET_DIR").map(PathBuf::from);
if let Some(path) = search(root, &cargo_config) {
let config: Config = parse(&path.join(&cargo_config))?;

if let Some(build) = config.build {
target = build.target;
target_dir = target_dir.or(build.target_dir.map(PathBuf::from));
}
} else if let Some(path) = search(root, &cargo_config_toml) {
let config: Config = parse(&path.join(&cargo_config_toml))?;

if let Some(build) = config.build {
target = build.target;
target_dir = target_dir.or(build.target_dir.map(PathBuf::from));
Expand Down

0 comments on commit 85d1924

Please sign in to comment.