diff options
-rw-r--r-- | Cargo.toml | 9 | ||||
-rw-r--r-- | build.rs | 14 |
2 files changed, 19 insertions, 4 deletions
@@ -23,6 +23,13 @@ default = ["builtin-lua"] # * LUA_EXTRASPACE is at least pointer sized and has at least pointer alignment. # * LUAI_MAXSTACK is 1_000_000 builtin-lua = ["cc"] +# Uses pkg-config to find an appropriate lua 5.3 library to link with. All of +# the caveats about disabling the default builtin-lua feature apply here as +# well. If neither the builtin-lua nor the system-lua feature is enabled, then +# no lua library will be linked at all and one must be linked with or built into +# the final binary manually. The builtin-lua and system-lua features are +# mutually exclusive and enabling both will cause an error at build time. +system-lua = ["pkg-config"] [dependencies] libc = { version = "0.2" } @@ -31,7 +38,7 @@ compiletest_rs = { version = "0.3", optional = true } [build-dependencies] cc = { version = "1.0", optional = true } -pkg-config = "0.3.11" +pkg-config = { version = "0.3.11", optional = true } [dev-dependencies] rustyline = "1.0.0" @@ -1,10 +1,14 @@ #[cfg(feature = "builtin-lua")] extern crate cc; -#[cfg(not(feature = "builtin-lua"))] +#[cfg(feature = "system-lua")] extern crate pkg_config; fn main() { + if cfg!(all(feature = "builtin-lua", feature = "system-lua")) { + panic!("cannot enable both builtin-lua and system-lua features when building rlua"); + } + #[cfg(feature = "builtin-lua")] { use std::env; @@ -65,8 +69,12 @@ fn main() { .file("lua/lzio.c") .compile("liblua5.3.a"); } - #[cfg(not(feature = "builtin-lua"))] + + #[cfg(feature = "system-lua")] { - pkg_config::Config::new().atleast_version("5.3").probe("lua").unwrap(); + pkg_config::Config::new() + .atleast_version("5.3") + .probe("lua") + .unwrap(); } } |