feat: update meson options for CMake, Meson, Perl, Python, and Rust packages; enhance configure help text validation
This commit is contained in:
+5
-5
@@ -19,19 +19,19 @@ option(
|
||||
option(
|
||||
'DEPOT_CMAKE_PACKAGE',
|
||||
type: 'string',
|
||||
value: '',
|
||||
value: 'cmake',
|
||||
description: 'Compile in the helper package to auto-install before CMake builds',
|
||||
)
|
||||
option(
|
||||
'DEPOT_MESON_PACKAGE',
|
||||
type: 'string',
|
||||
value: '',
|
||||
value: 'meson',
|
||||
description: 'Compile in the helper package to auto-install before Meson builds',
|
||||
)
|
||||
option(
|
||||
'DEPOT_PERL_PACKAGE',
|
||||
type: 'string',
|
||||
value: '',
|
||||
value: 'perl',
|
||||
description: 'Compile in the helper package to auto-install before Perl builds',
|
||||
)
|
||||
option(
|
||||
@@ -43,13 +43,13 @@ option(
|
||||
option(
|
||||
'DEPOT_PYTHON_PACKAGE',
|
||||
type: 'string',
|
||||
value: '',
|
||||
value: 'python',
|
||||
description: 'Compile in the helper package to auto-install before Python builds',
|
||||
)
|
||||
option(
|
||||
'DEPOT_RUST_PACKAGE',
|
||||
type: 'string',
|
||||
value: '',
|
||||
value: 'rust',
|
||||
description: 'Compile in the helper package to auto-install before Rust builds',
|
||||
)
|
||||
option(
|
||||
|
||||
@@ -550,13 +550,26 @@ fn configure_help_text(
|
||||
help_cmd.arg("--help");
|
||||
crate::builder::prepare_command(&mut help_cmd, env_vars);
|
||||
let output = help_cmd.output().ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
let mut text = String::new();
|
||||
text.push_str(&String::from_utf8_lossy(&output.stdout));
|
||||
text.push_str(&String::from_utf8_lossy(&output.stderr));
|
||||
Some(text)
|
||||
if output.status.success() || looks_like_configure_help_text(&text) {
|
||||
return Some(text);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn looks_like_configure_help_text(text: &str) -> bool {
|
||||
let trimmed = text.trim();
|
||||
if trimmed.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let lower = trimmed.to_ascii_lowercase();
|
||||
lower.contains("usage:")
|
||||
|| lower.contains("options:")
|
||||
|| lower.contains("--help")
|
||||
|| lower.contains("--prefix")
|
||||
}
|
||||
|
||||
fn configure_help_supports_option(help_text: &str, option: &str) -> bool {
|
||||
@@ -1081,6 +1094,24 @@ mod tests {
|
||||
assert!(configure_help_supports_option(help, "--without-zlib"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_looks_like_configure_help_text_accepts_bootstrap_style_output() {
|
||||
let help = "\
|
||||
Usage: ./bootstrap [<options>...]
|
||||
Options:
|
||||
--help
|
||||
--prefix=PREFIX";
|
||||
assert!(looks_like_configure_help_text(help));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_looks_like_configure_help_text_rejects_non_help_output() {
|
||||
assert!(!looks_like_configure_help_text(""));
|
||||
assert!(!looks_like_configure_help_text(
|
||||
"Unknown option: --disable-static"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_configure_supports_option_defaults_by_configure_file_usage() {
|
||||
assert!(configure_supports_option(None, "--host", ""));
|
||||
|
||||
Reference in New Issue
Block a user