summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2024-06-19 15:32:58 +0200
committercos <cos>2024-06-26 16:13:50 +0200
commit68846288c80c6d25d9d3d5e37875ae7ff9224408 (patch)
tree96eedd3ad6f160c47065443269ebd221c9c96f4d
parent0a1f625f814a3bff8b3b092add0af0cd4817f611 (diff)
downloadmlua-topic/freebsd-0.10.zip
Make build script work with FreeBSDtopic/freebsd-0.10
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.rs24
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}"));