Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cargo-dist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ current_platform.workspace = true
color-backtrace.workspace = true
backtrace.workspace = true
schemars.workspace = true
cargo-config2 = "0.1.36"

[dev-dependencies]
insta.workspace = true
Expand Down
17 changes: 16 additions & 1 deletion cargo-dist/src/build/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,22 @@ impl<'a> DistGraphBuilder<'a> {
let mut builds = vec![];
for (target_triple, binaries) in targets {
let target = target_triple.parse()?;
let mut rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();

// If RUSTFLAGS is set, use that.
// Otherwise, read .cargo/config.toml.
let mut rustflags = match std::env::var("RUSTFLAGS") {
Ok(rustflags) => rustflags,
Err(_) => {
let config = cargo_config2::Config::load()?;
let flags = config
.rustflags(target_triple.as_str())?
.unwrap_or_default();
// Convert from Vec<String> to a single space-separated String.
flags.flags.join(" ")
}
};

// let mut rustflags = std::env::var("RUSTFLAGS").unwrap_or_default();

// FIXME: is there a more principled way for us to add things to RUSTFLAGS
// without breaking everything. Cargo has some builtin ways like keys
Expand Down
4 changes: 4 additions & 0 deletions cargo-dist/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ pub enum DistError {
#[error(transparent)]
TripleError(#[from] cargo_dist_schema::target_lexicon::ParseError),

/// random cargo_config2 error
#[error(transparent)]
ConfigError(#[from] cargo_config2::Error),

/// A problem with a jinja template, which is always a dist bug
#[error("Failed to render template")]
#[diagnostic(
Expand Down