Add lib32 companion build pipeline
This commit is contained in:
@@ -40,7 +40,10 @@ pub fn build(
|
||||
}
|
||||
|
||||
use crate::builder::state::{BuildStep, StateTracker};
|
||||
let mut state = StateTracker::new(&actual_src)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
&actual_src,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
|
||||
// Run configure
|
||||
let build_dir = if let Some(dir) = &flags.build_dir {
|
||||
@@ -78,7 +81,14 @@ pub fn build(
|
||||
Some(flags.chost.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
}
|
||||
.map(|host| {
|
||||
if flags.lib32_variant {
|
||||
lib32_host_triple(&host)
|
||||
} else {
|
||||
host
|
||||
}
|
||||
});
|
||||
|
||||
let requested_build = if cross.is_some() {
|
||||
CrossConfig::build_triple().ok()
|
||||
@@ -104,6 +114,15 @@ pub fn build(
|
||||
}
|
||||
}
|
||||
|
||||
if flags.lib32_variant {
|
||||
if !has_configure_option_prefix(&flags.configure, "--libdir") {
|
||||
configure_cmd.arg("--libdir=/usr/lib32");
|
||||
}
|
||||
if !has_configure_option_prefix(&flags.configure, "--libexecdir") {
|
||||
configure_cmd.arg("--libexecdir=/usr/lib32");
|
||||
}
|
||||
}
|
||||
|
||||
for arg in &flags.configure {
|
||||
let expanded = expand_configure_arg(spec, arg, &env_vars);
|
||||
configure_cmd.arg(expanded);
|
||||
@@ -412,6 +431,18 @@ fn configure_supports_option(help_text: Option<&str>, option: &str, configure_fi
|
||||
.unwrap_or(configure_file.trim().is_empty())
|
||||
}
|
||||
|
||||
fn has_configure_option_prefix(args: &[String], option: &str) -> bool {
|
||||
let with_eq = format!("{option}=");
|
||||
args.iter().any(|arg| {
|
||||
let trimmed = arg.trim();
|
||||
trimmed == option || trimmed.starts_with(&with_eq)
|
||||
})
|
||||
}
|
||||
|
||||
fn lib32_host_triple(host: &str) -> String {
|
||||
host.replace("x86_64", "i686")
|
||||
}
|
||||
|
||||
fn find_autotools_test_target(build_dir: &Path) -> Result<Option<&'static str>> {
|
||||
for target in ["check", "test"] {
|
||||
if makefile_has_target(build_dir, target)? {
|
||||
|
||||
@@ -46,7 +46,10 @@ pub fn build(
|
||||
};
|
||||
|
||||
use crate::builder::state::{BuildStep, StateTracker};
|
||||
let mut state = StateTracker::new(&actual_src)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
&actual_src,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
|
||||
// Run cmake configure
|
||||
if !state.is_done(BuildStep::Configured) {
|
||||
|
||||
@@ -59,7 +59,10 @@ pub fn build(
|
||||
}
|
||||
|
||||
use crate::builder::state::{BuildStep, StateTracker};
|
||||
let mut state = StateTracker::new(src_dir)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
src_dir,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
|
||||
if !state.is_done(BuildStep::Configured) {
|
||||
hooks::run_post_configure_commands(spec, src_dir, destdir)?;
|
||||
|
||||
@@ -12,7 +12,10 @@ pub fn build(
|
||||
cross: Option<&CrossConfig>,
|
||||
export_compiler_flags: bool,
|
||||
) -> Result<()> {
|
||||
let mut state = StateTracker::new(src_dir)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
src_dir,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
let flags = &spec.build.flags;
|
||||
|
||||
let mut env_vars = crate::builder::standard_build_env(spec, cross, true, export_compiler_flags);
|
||||
|
||||
@@ -37,7 +37,10 @@ pub fn build(
|
||||
};
|
||||
|
||||
use crate::builder::state::{BuildStep, StateTracker};
|
||||
let mut state = StateTracker::new(&actual_src)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
&actual_src,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
|
||||
// Run meson setup
|
||||
if !state.is_done(BuildStep::Configured) {
|
||||
|
||||
@@ -43,7 +43,10 @@ pub fn build(
|
||||
crate::builder::set_env_var(&mut env_vars, "PYTHONDONTWRITEBYTECODE", "1");
|
||||
crate::builder::set_env_var(&mut env_vars, "SETUPTOOLS_USE_DISTUTILS", "local");
|
||||
|
||||
let mut state = StateTracker::new(&actual_src)?;
|
||||
let mut state = StateTracker::new_with_namespace(
|
||||
&actual_src,
|
||||
spec.build.flags.lib32_variant.then_some("lib32"),
|
||||
)?;
|
||||
if !state.is_done(BuildStep::Configured) {
|
||||
hooks::run_post_configure_commands(spec, &actual_src, destdir)?;
|
||||
state.mark_done(BuildStep::Configured)?;
|
||||
|
||||
+28
-1
@@ -27,7 +27,15 @@ pub struct StateTracker {
|
||||
|
||||
impl StateTracker {
|
||||
pub fn new(source_dir: &Path) -> Result<Self> {
|
||||
let state_file = source_dir.join(".depot_state");
|
||||
Self::new_with_namespace(source_dir, None)
|
||||
}
|
||||
|
||||
pub fn new_with_namespace(source_dir: &Path, namespace: Option<&str>) -> Result<Self> {
|
||||
let state_file = if let Some(ns) = namespace.and_then(normalize_state_namespace) {
|
||||
source_dir.join(format!(".depot_state_{}", ns))
|
||||
} else {
|
||||
source_dir.join(".depot_state")
|
||||
};
|
||||
let state = if state_file.exists() {
|
||||
let content = fs::read_to_string(&state_file)?;
|
||||
toml::from_str(&content).unwrap_or_default()
|
||||
@@ -54,6 +62,25 @@ impl StateTracker {
|
||||
}
|
||||
}
|
||||
|
||||
fn normalize_state_namespace(namespace: &str) -> Option<String> {
|
||||
let normalized: String = namespace
|
||||
.chars()
|
||||
.map(|ch| {
|
||||
if ch.is_ascii_alphanumeric() || ch == '-' || ch == '_' {
|
||||
ch
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let trimmed = normalized.trim_matches('_');
|
||||
if trimmed.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(trimmed.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user