feat: update depot version to 0.34.1 and enhance configure argument handling

This commit is contained in:
2026-03-29 17:04:38 -05:00
parent 57a364aa97
commit d7afe5486d
4 changed files with 111 additions and 7 deletions
Generated
+1 -1
View File
@@ -451,7 +451,7 @@ checksum = "807800ff3288b621186fe0a8f3392c4652068257302709c24efd918c3dffcdc2"
[[package]] [[package]]
name = "depot" name = "depot"
version = "0.34.0" version = "0.34.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "depot" name = "depot"
version = "0.34.0" version = "0.34.1"
edition = "2024" edition = "2024"
[lints.rust] [lints.rust]
+1 -1
View File
@@ -1,6 +1,6 @@
project( project(
'depot', 'depot',
version: '0.34.0', version: '0.34.1',
meson_version: '>=0.60.0', meson_version: '>=0.60.0',
default_options: ['buildtype=release'], default_options: ['buildtype=release'],
) )
+108 -4
View File
@@ -132,10 +132,10 @@ pub fn build(
for arg in &flags.configure { for arg in &flags.configure {
let expanded = expand_configure_arg(spec, arg, &env_vars); let expanded = expand_configure_arg(spec, arg, &env_vars);
configure_cmd.arg(expanded); add_configure_arg_if_supported(&mut configure_cmd, help_text.as_deref(), &expanded);
} }
for arg in crate::builder::static_build_args_for(crate::package::BuildType::Autotools)? { for arg in crate::builder::static_build_args_for(crate::package::BuildType::Autotools)? {
configure_cmd.arg(arg); add_configure_arg_if_supported(&mut configure_cmd, help_text.as_deref(), &arg);
} }
let status = crate::interrupts::command_status(&mut configure_cmd) let status = crate::interrupts::command_status(&mut configure_cmd)
@@ -442,10 +442,10 @@ pub(crate) fn ensure_host_build(
} }
for arg in &flags.configure { for arg in &flags.configure {
let expanded = expand_configure_arg(&host_spec, arg, &env_vars); let expanded = expand_configure_arg(&host_spec, arg, &env_vars);
configure_cmd.arg(expanded); add_configure_arg_if_supported(&mut configure_cmd, help_text.as_deref(), &expanded);
} }
for arg in crate::builder::static_build_args_for(crate::package::BuildType::Autotools)? { for arg in crate::builder::static_build_args_for(crate::package::BuildType::Autotools)? {
configure_cmd.arg(arg); add_configure_arg_if_supported(&mut configure_cmd, help_text.as_deref(), &arg);
} }
let status = crate::interrupts::command_status(&mut configure_cmd) let status = crate::interrupts::command_status(&mut configure_cmd)
@@ -560,11 +560,36 @@ fn configure_help_text(
} }
fn configure_help_supports_option(help_text: &str, option: &str) -> bool { fn configure_help_supports_option(help_text: &str, option: &str) -> bool {
configure_help_option_aliases(option)
.iter()
.any(|candidate| configure_help_mentions_option(help_text, candidate))
}
fn configure_help_mentions_option(help_text: &str, option: &str) -> bool {
let with_eq = format!("{}=", option); let with_eq = format!("{}=", option);
let with_space = format!("{} ", option); let with_space = format!("{} ", option);
help_text.contains(&with_eq) || help_text.contains(&with_space) || help_text.contains(option) help_text.contains(&with_eq) || help_text.contains(&with_space) || help_text.contains(option)
} }
fn configure_help_option_aliases(option: &str) -> Vec<String> {
let mut aliases = vec![option.to_string()];
if let Some(feature) = option.strip_prefix("--enable-") {
aliases.push(format!("--disable-{feature}"));
}
if let Some(feature) = option.strip_prefix("--disable-") {
aliases.push(format!("--enable-{feature}"));
}
if let Some(feature) = option.strip_prefix("--with-") {
aliases.push(format!("--without-{feature}"));
}
if let Some(feature) = option.strip_prefix("--without-") {
aliases.push(format!("--with-{feature}"));
}
aliases
}
fn configure_supports_option(help_text: Option<&str>, option: &str, configure_file: &str) -> bool { fn configure_supports_option(help_text: Option<&str>, option: &str, configure_file: &str) -> bool {
help_text help_text
.map(|text| configure_help_supports_option(text, option)) .map(|text| configure_help_supports_option(text, option))
@@ -579,6 +604,39 @@ fn has_configure_option_prefix(args: &[String], option: &str) -> bool {
}) })
} }
fn configure_long_option(arg: &str) -> Option<&str> {
let trimmed = arg.trim();
if !trimmed.starts_with("--") || trimmed == "--" {
return None;
}
let end = trimmed
.find(|ch: char| ch == '=' || ch.is_whitespace())
.unwrap_or(trimmed.len());
Some(&trimmed[..end])
}
fn add_configure_arg_if_supported(configure_cmd: &mut Command, help_text: Option<&str>, arg: &str) {
if let Some(help_text) = help_text
&& let Some(option) = configure_long_option(arg)
&& !configure_help_supports_option(help_text, option)
{
let trimmed = arg.trim();
if trimmed == option {
crate::log_info!(" configure does not support {}; skipping", option);
} else {
crate::log_info!(
" configure does not support {}; skipping {}",
option,
trimmed
);
}
return;
}
configure_cmd.arg(arg);
}
fn default_configure_install_dirs( fn default_configure_install_dirs(
flags: &crate::package::BuildFlags, flags: &crate::package::BuildFlags,
help_text: Option<&str>, help_text: Option<&str>,
@@ -1016,6 +1074,13 @@ mod tests {
assert!(!configure_help_supports_option(help, "--target")); assert!(!configure_help_supports_option(help, "--target"));
} }
#[test]
fn test_configure_help_supports_enable_disable_aliases() {
let help = " --enable-static build static libraries\n --with-zlib=DIR";
assert!(configure_help_supports_option(help, "--disable-static"));
assert!(configure_help_supports_option(help, "--without-zlib"));
}
#[test] #[test]
fn test_configure_supports_option_defaults_by_configure_file_usage() { fn test_configure_supports_option_defaults_by_configure_file_usage() {
assert!(configure_supports_option(None, "--host", "")); assert!(configure_supports_option(None, "--host", ""));
@@ -1094,6 +1159,45 @@ mod tests {
assert!(args.is_empty()); assert!(args.is_empty());
} }
#[test]
fn test_configure_long_option_extracts_long_option_name() {
assert_eq!(
configure_long_option(" --disable-static "),
Some("--disable-static")
);
assert_eq!(
configure_long_option("--with-zlib=/usr"),
Some("--with-zlib")
);
assert_eq!(configure_long_option("prefix=/usr"), None);
assert_eq!(configure_long_option("-C"), None);
}
#[test]
fn test_add_configure_arg_if_supported_skips_unsupported_long_option() {
let mut cmd = Command::new("configure");
add_configure_arg_if_supported(&mut cmd, Some("--enable-static"), "--disable-nls");
let args: Vec<String> = cmd
.get_args()
.map(|arg| arg.to_string_lossy().to_string())
.collect();
assert!(args.is_empty());
}
#[test]
fn test_add_configure_arg_if_supported_keeps_supported_alias_and_non_option_args() {
let mut cmd = Command::new("configure");
add_configure_arg_if_supported(&mut cmd, Some("--enable-static"), "--disable-static");
add_configure_arg_if_supported(&mut cmd, Some("--enable-static"), "srcdir");
let args: Vec<String> = cmd
.get_args()
.map(|arg| arg.to_string_lossy().to_string())
.collect();
assert_eq!(args, vec!["--disable-static", "srcdir"]);
}
#[test] #[test]
fn test_install_destdir_path_uses_build_dir_for_lib32() { fn test_install_destdir_path_uses_build_dir_for_lib32() {
let build_dir = Path::new("/tmp/build"); let build_dir = Path::new("/tmp/build");