diff options
author | cos <cos> | 2024-06-19 15:32:58 +0200 |
---|---|---|
committer | cos <cos> | 2024-06-19 15:36:02 +0200 |
commit | e790741e5a24378567448a667dd2dad728fc6ed8 (patch) | |
tree | d108418de9949b820d3ab43bf847628790b8c136 | |
parent | f1ceaf0ff19285f326b84228fc9ccad73e7c968d (diff) | |
download | mlua-topic/freebsd.zip |
Make build script work with FreeBSDtopic/freebsd
On FreeBSD the pkg-config names takes the format with a dash, rather
than without (e.g. lua-5.4, not lua5.4). Thus adapt build script to
iterate over an array of alt_probes until finding a match.
-rw-r--r-- | mlua-sys/build/find_normal.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/mlua-sys/build/find_normal.rs b/mlua-sys/build/find_normal.rs index 26b1200..4fa874a 100644 --- a/mlua-sys/build/find_normal.rs +++ b/mlua-sys/build/find_normal.rs @@ -32,15 +32,15 @@ pub fn probe_lua() { // Find using `pkg-config` #[cfg(feature = "lua54")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.4", "5.5", Some("lua5.4"), "5.4"); + let (incl_bound, excl_bound, alt_probe, ver) = ("5.4", "5.5", ["lua5.4", "lua-5.4"], "5.4"); #[cfg(feature = "lua53")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.3", "5.4", Some("lua5.3"), "5.3"); + let (incl_bound, excl_bound, alt_probe, ver) = ("5.3", "5.4", ["lua5.3", "lua-5.3"], "5.3"); #[cfg(feature = "lua52")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.2", "5.3", Some("lua5.2"), "5.2"); + let (incl_bound, excl_bound, alt_probe, ver) = ("5.2", "5.3", ["lua5.2", "lua-5.2"], "5.2"); #[cfg(feature = "lua51")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.1", "5.2", Some("lua5.1"), "5.1"); + let (incl_bound, excl_bound, alt_probe, ver) = ("5.1", "5.2", ["lua5.1", "lua-5.1"], "5.1"); #[cfg(feature = "luajit")] - let (incl_bound, excl_bound, alt_probe, ver) = ("2.0.4", "2.2", None, "JIT"); + let (incl_bound, excl_bound, alt_probe, ver) = ("2.0.4", "2.2", [], "JIT"); #[rustfmt::skip] let mut lua = pkg_config::Config::new() @@ -48,10 +48,16 @@ pub fn probe_lua() { .cargo_metadata(true) .probe(if cfg!(feature = "luajit") { "luajit" } else { "lua" }); - if lua.is_err() && alt_probe.is_some() { - lua = pkg_config::Config::new() - .cargo_metadata(true) - .probe(alt_probe.unwrap()); + if lua.is_err() { + for pkg in alt_probe { + lua = pkg_config::Config::new() + .cargo_metadata(true) + .probe(pkg); + + if lua.is_ok() { + break; + } + } } lua.unwrap_or_else(|err| panic!("cannot find Lua{ver} using `pkg-config`: {err}")); |