From 2b4d362a90e789142ea5cbe16487e36cbdb4a9cc Mon Sep 17 00:00:00 2001 From: slowsage <84777606+slowsage@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:54:05 -0500 Subject: [PATCH 1/2] feat(mlua-sys): add system-deps metadata section --- mlua-sys/Cargo.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mlua-sys/Cargo.toml b/mlua-sys/Cargo.toml index 3029566d..ea135fdb 100644 --- a/mlua-sys/Cargo.toml +++ b/mlua-sys/Cargo.toml @@ -47,3 +47,11 @@ luau0-src = { version = "0.18.0", optional = true } [lints.rust] unexpected_cfgs = { level = "allow", check-cfg = ['cfg(raw_dylib)'] } + +[package.metadata.system-deps] +lua55 = { name = "lua", fallback-names = ["lua5.5", "lua-5.5", "lua55"], version = ">= 5.5, < 5.6", feature = "lua55" } +lua54 = { name = "lua", fallback-names = ["lua5.4", "lua-5.4", "lua54"], version = ">= 5.4, < 5.5", feature = "lua54" } +lua53 = { name = "lua", fallback-names = ["lua5.3", "lua-5.3", "lua53"], version = ">= 5.3, < 5.4", feature = "lua53" } +lua52 = { name = "lua", fallback-names = ["lua5.2", "lua-5.2", "lua52"], version = ">= 5.2, < 5.3", feature = "lua52" } +lua51 = { name = "lua", fallback-names = ["lua5.1", "lua-5.1", "lua51"], version = ">= 5.1, < 5.2", feature = "lua51" } +luajit = { name = "luajit", version = ">= 2.0.4, < 2.2", feature = "luajit" } From d8c07dfad4bf221a991080d09386c97e5c736dd6 Mon Sep 17 00:00:00 2001 From: slowsage <84777606+slowsage@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:56:09 -0500 Subject: [PATCH 2/2] refactor(mlua-sys): migrate from pkg-config to system-deps --- mlua-sys/Cargo.toml | 2 +- mlua-sys/build/find_normal.rs | 35 ++--------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/mlua-sys/Cargo.toml b/mlua-sys/Cargo.toml index ea135fdb..08c5842d 100644 --- a/mlua-sys/Cargo.toml +++ b/mlua-sys/Cargo.toml @@ -40,7 +40,7 @@ libc = "0.2" [build-dependencies] cc = "1.0" cfg-if = "1.0" -pkg-config = "0.3.17" +system-deps = "7.0" lua-src = { version = ">= 550.0.0, < 550.1.0", optional = true } luajit-src = { version = ">= 210.6.0, < 210.7.0", optional = true } luau0-src = { version = "0.18.0", optional = true } diff --git a/mlua-sys/build/find_normal.rs b/mlua-sys/build/find_normal.rs index b91b1c01..a35866c2 100644 --- a/mlua-sys/build/find_normal.rs +++ b/mlua-sys/build/find_normal.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] use std::env; -use std::ops::Bound; pub fn probe_lua() { let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); @@ -29,36 +28,6 @@ pub fn probe_lua() { return; } - // Find using `pkg-config` - - #[cfg(feature = "lua55")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.5", "5.6", ["lua5.5", "lua-5.5", "lua55"], "5.5"); - #[cfg(feature = "lua54")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.4", "5.5", ["lua5.4", "lua-5.4", "lua54"], "5.4"); - #[cfg(feature = "lua53")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.3", "5.4", ["lua5.3", "lua-5.3", "lua53"], "5.3"); - #[cfg(feature = "lua52")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.2", "5.3", ["lua5.2", "lua-5.2", "lua52"], "5.2"); - #[cfg(feature = "lua51")] - let (incl_bound, excl_bound, alt_probe, ver) = ("5.1", "5.2", ["lua5.1", "lua-5.1", "lua51"], "5.1"); - #[cfg(feature = "luajit")] - let (incl_bound, excl_bound, alt_probe, ver) = ("2.0.4", "2.2", [], "JIT"); - - #[rustfmt::skip] - let mut lua = pkg_config::Config::new() - .range_version((Bound::Included(incl_bound), Bound::Excluded(excl_bound))) - .cargo_metadata(true) - .probe(if cfg!(feature = "luajit") { "luajit" } else { "lua" }); - - 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}")); + // This reads [package.metadata.system-deps] from Cargo.toml + system_deps::Config::new().probe().unwrap(); }