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

support .cargo/config.toml #10

Closed
wants to merge 1 commit into from
Closed
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
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit clearer:

Suggested change
let cargo_config_toml = Path::new(".cargo").join("config.toml");
let cargo_config_toml = cargo_config.with_extension("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))?;
benmkw marked this conversation as resolved.
Show resolved Hide resolved

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