30 releases

0.1.29 Sep 1, 2024
0.1.27 Aug 19, 2024
0.1.26 Apr 20, 2024
0.1.23 Mar 29, 2024
0.1.6 Mar 7, 2023

#12 in Build Utils

Download history 30182/week @ 2024-08-03 27394/week @ 2024-08-10 32762/week @ 2024-08-17 33876/week @ 2024-08-24 35577/week @ 2024-08-31 38094/week @ 2024-09-07 31839/week @ 2024-09-14 40634/week @ 2024-09-21 36033/week @ 2024-09-28 38305/week @ 2024-10-05 40123/week @ 2024-10-12 39677/week @ 2024-10-19 37411/week @ 2024-10-26 39141/week @ 2024-11-02 51337/week @ 2024-11-09 53832/week @ 2024-11-16

188,082 downloads per month
Used in 33 crates (12 directly)

Apache-2.0 OR MIT

265KB
5K SLoC

cargo-config2

crates.io docs.rs license msrv github actions

Load and resolve Cargo configuration.

This library is intended to accurately emulate the actual behavior of Cargo configuration, for example, this supports the following behaviors:

Supported tables and fields are mainly based on cargo-llvm-cov's use cases, but feel free to submit an issue if you see something missing in your use case.

Usage

Add this to your Cargo.toml:

[dependencies]
cargo-config2 = "0.1"

cargo-config2 is usually runnable with Cargo versions older than the Rust version required for build. (e.g., a cargo subcommand using cargo-config2 could work with older versions such as cargo +1.59 <subcommand>.)

Examples

// Read config files hierarchically from the current directory, merge them,
// apply environment variables, and resolve relative paths.
let config = cargo_config2::Config::load()?;
let target = "x86_64-unknown-linux-gnu";
// Resolve target-specific configuration (`target.<triple>` and `target.<cfg>`),
// and returns the resolved rustflags for `target`.
let rustflags = config.rustflags(target)?;
println!("{rustflags:?}");

See also the get example that partial re-implementation of cargo config get using cargo-config2.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Third party software

This product includes copies and modifications of software developed by third parties:

See the license files included in these directories for more details.

Dependencies

~2.2–9.5MB
~95K SLoC