Crates.io | cargo-config2 |
lib.rs | cargo-config2 |
version | 0.1.29 |
source | src |
created_at | 2023-01-09 09:56:28.911975 |
updated_at | 2024-09-01 07:36:36.332647 |
description | Load and resolve Cargo configuration. |
homepage | |
repository | https://github.com/taiki-e/cargo-config2 |
max_upload_size | |
id | 754279 |
size | 325,454 |
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:
target.<triple>
and target.<cfg>
resolution.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.
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>
.)
// 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.
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.
This product includes copies and modifications of software developed by third parties:
src/cfg_expr
includes copies and modifications of cfg-expr
crate by Embark Studios, licensed under "Apache-2.0 OR MIT".See the license files included in these directories for more details.