Skip to content

Commit c31c720

Browse files
coskhvzak
authored andcommitted
Make build script work with 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. Signed-off-by: Alex Orlenko <[email protected]>
1 parent 3bfaee4 commit c31c720

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

mlua-sys/build/find_normal.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,32 @@ pub fn probe_lua() {
3232
// Find using `pkg-config`
3333

3434
#[cfg(feature = "lua54")]
35-
let (incl_bound, excl_bound, alt_probe, ver) = ("5.4", "5.5", Some("lua5.4"), "5.4");
35+
let (incl_bound, excl_bound, alt_probe, ver) = ("5.4", "5.5", ["lua5.4", "lua-5.4"], "5.4");
3636
#[cfg(feature = "lua53")]
37-
let (incl_bound, excl_bound, alt_probe, ver) = ("5.3", "5.4", Some("lua5.3"), "5.3");
37+
let (incl_bound, excl_bound, alt_probe, ver) = ("5.3", "5.4", ["lua5.3", "lua-5.3"], "5.3");
3838
#[cfg(feature = "lua52")]
39-
let (incl_bound, excl_bound, alt_probe, ver) = ("5.2", "5.3", Some("lua5.2"), "5.2");
39+
let (incl_bound, excl_bound, alt_probe, ver) = ("5.2", "5.3", ["lua5.2", "lua-5.2"], "5.2");
4040
#[cfg(feature = "lua51")]
41-
let (incl_bound, excl_bound, alt_probe, ver) = ("5.1", "5.2", Some("lua5.1"), "5.1");
41+
let (incl_bound, excl_bound, alt_probe, ver) = ("5.1", "5.2", ["lua5.1", "lua-5.1"], "5.1");
4242
#[cfg(feature = "luajit")]
43-
let (incl_bound, excl_bound, alt_probe, ver) = ("2.0.4", "2.2", None, "JIT");
43+
let (incl_bound, excl_bound, alt_probe, ver) = ("2.0.4", "2.2", [], "JIT");
4444

4545
#[rustfmt::skip]
4646
let mut lua = pkg_config::Config::new()
4747
.range_version((Bound::Included(incl_bound), Bound::Excluded(excl_bound)))
4848
.cargo_metadata(true)
4949
.probe(if cfg!(feature = "luajit") { "luajit" } else { "lua" });
5050

51-
if lua.is_err() && alt_probe.is_some() {
52-
lua = pkg_config::Config::new()
53-
.cargo_metadata(true)
54-
.probe(alt_probe.unwrap());
51+
if lua.is_err() {
52+
for pkg in alt_probe {
53+
lua = pkg_config::Config::new()
54+
.cargo_metadata(true)
55+
.probe(pkg);
56+
57+
if lua.is_ok() {
58+
break;
59+
}
60+
}
5561
}
5662

5763
lua.unwrap_or_else(|err| panic!("cannot find Lua{ver} using `pkg-config`: {err}"));

0 commit comments

Comments
 (0)