From 85d19248bb26746402cb5ffca3f84a08defee590 Mon Sep 17 00:00:00 2001 From: Benedikt Mandelkow Date: Sat, 22 Aug 2020 14:17:55 +0200 Subject: [PATCH] support .cargo/config.toml closes https://github.com/japaric/cargo-project/issues/9 ref https://github.com/probe-rs/cargo-embed/issues/29 --- src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e2571da..1e59d06 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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::(&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));