[go: up one dir, main page]

Crate cargo_config2

Source
Expand description

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.

§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.

Re-exports§

pub use crate::de::Color;
pub use crate::de::Frequency;
pub use crate::de::RegistriesProtocol;
pub use crate::de::VersionControlSoftware;
pub use crate::de::When;

Modules§

de
Cargo configuration that environment variables, config overrides, and target-specific configurations have not been resolved.

Structs§

BuildConfig
The [build] table.
CargoNewConfig
The [cargo-new] table.
CargoVersion
Config
Cargo configuration.
DocConfig
The [doc] table.
EnvConfigValue
A value of the [env] table.
Error
An error that occurred during loading or resolving the Cargo configuration.
Flags
A representation of rustflags or rustdocflags.
FutureIncompatReportConfig
The [future-incompat-report] table.
HttpConfig
The [http] table.
NetConfig
The [net] table.
PathAndArgs
An executable path with arguments.
RegistriesConfigValue
A value of the [registries] table.
RegistryConfig
The [registry] table.
ResolveOptions
RustcVersion
StringList
A list of string.
TargetConfig
A [target.<triple>] or [target.<cfg>] table.
TargetTripleRef
TermConfig
The [term] table.
TermProgressConfig
Walk
An iterator over Cargo configuration file paths.

Functions§

cargo_home_with_cwd
home_dir
rustup_home_with_cwd

Type Aliases§

TargetTriple