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(
|
option(
|
||||||
'DEPOT_CMAKE_PACKAGE',
|
'DEPOT_CMAKE_PACKAGE',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
value: '',
|
value: 'cmake',
|
||||||
description: 'Compile in the helper package to auto-install before CMake builds',
|
description: 'Compile in the helper package to auto-install before CMake builds',
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
'DEPOT_MESON_PACKAGE',
|
'DEPOT_MESON_PACKAGE',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
value: '',
|
value: 'meson',
|
||||||
description: 'Compile in the helper package to auto-install before Meson builds',
|
description: 'Compile in the helper package to auto-install before Meson builds',
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
'DEPOT_PERL_PACKAGE',
|
'DEPOT_PERL_PACKAGE',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
value: '',
|
value: 'perl',
|
||||||
description: 'Compile in the helper package to auto-install before Perl builds',
|
description: 'Compile in the helper package to auto-install before Perl builds',
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
@@ -43,13 +43,13 @@ option(
|
|||||||
option(
|
option(
|
||||||
'DEPOT_PYTHON_PACKAGE',
|
'DEPOT_PYTHON_PACKAGE',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
value: '',
|
value: 'python',
|
||||||
description: 'Compile in the helper package to auto-install before Python builds',
|
description: 'Compile in the helper package to auto-install before Python builds',
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
'DEPOT_RUST_PACKAGE',
|
'DEPOT_RUST_PACKAGE',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
value: '',
|
value: 'rust',
|
||||||
description: 'Compile in the helper package to auto-install before Rust builds',
|
description: 'Compile in the helper package to auto-install before Rust builds',
|
||||||
)
|
)
|
||||||
option(
|
option(
|
||||||
|
|||||||
@@ -550,13 +550,26 @@ fn configure_help_text(
|
|||||||
help_cmd.arg("--help");
|
help_cmd.arg("--help");
|
||||||
crate::builder::prepare_command(&mut help_cmd, env_vars);
|
crate::builder::prepare_command(&mut help_cmd, env_vars);
|
||||||
let output = help_cmd.output().ok()?;
|
let output = help_cmd.output().ok()?;
|
||||||
if !output.status.success() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
text.push_str(&String::from_utf8_lossy(&output.stdout));
|
text.push_str(&String::from_utf8_lossy(&output.stdout));
|
||||||
text.push_str(&String::from_utf8_lossy(&output.stderr));
|
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 {
|
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"));
|
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]
|
#[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", ""));
|
||||||
|
|||||||
Reference in New Issue
Block a user