summaryrefslogtreecommitdiff
path: root/build/find_normal.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2020-05-31 12:16:47 +0100
committerAlex Orlenko <zxteam@protonmail.com>2020-06-07 20:38:11 +0100
commit5952a1f709df38bd7b74edd815620f16225dcf8e (patch)
tree116ea1583e6922be1e07997afb0f726cb5c1083a /build/find_normal.rs
parent73c7c94d7523eced1b0b9fff0d26ef14928dfdc3 (diff)
downloadmlua-5952a1f709df38bd7b74edd815620f16225dcf8e.zip
New `module` feature
Don't link module with Lua core (see: http://lua-users.org/wiki/BuildingModules) Example and tests for modules
Diffstat (limited to 'build/find_normal.rs')
-rw-r--r--build/find_normal.rs50
1 files changed, 35 insertions, 15 deletions
diff --git a/build/find_normal.rs b/build/find_normal.rs
index 31be3e1..0edc22c 100644
--- a/build/find_normal.rs
+++ b/build/find_normal.rs
@@ -14,21 +14,29 @@ pub fn probe_lua() -> PathBuf {
println!("cargo:rerun-if-env-changed=LUA_LIB_NAME");
println!("cargo:rerun-if-env-changed=LUA_LINK");
- if include_dir != "" && lib_dir != "" && lua_lib != "" {
+ let need_lua_lib = cfg!(any(not(feature = "module"), target_os = "windows"));
+
+ if include_dir != "" && (!need_lua_lib || lib_dir != "") {
+ if lua_lib == "" {
+ panic!("LUA_LIB_NAME is not set");
+ }
let _version = use_custom_lua(&include_dir, &lib_dir, &lua_lib).unwrap();
return PathBuf::from(include_dir);
}
- // Find using via pkg-config
+ // Find using `pkg-config`
#[cfg(feature = "lua54")]
{
let mut lua = pkg_config::Config::new()
.range_version((Bound::Included("5.4"), Bound::Excluded("5.5")))
+ .cargo_metadata(need_lua_lib)
.probe("lua");
if lua.is_err() {
- lua = pkg_config::Config::new().probe("lua5.4");
+ lua = pkg_config::Config::new()
+ .cargo_metadata(need_lua_lib)
+ .probe("lua5.4");
}
lua.unwrap().include_paths[0].clone()
@@ -38,10 +46,13 @@ pub fn probe_lua() -> PathBuf {
{
let mut lua = pkg_config::Config::new()
.range_version((Bound::Included("5.3"), Bound::Excluded("5.4")))
+ .cargo_metadata(need_lua_lib)
.probe("lua");
if lua.is_err() {
- lua = pkg_config::Config::new().probe("lua5.3");
+ lua = pkg_config::Config::new()
+ .cargo_metadata(need_lua_lib)
+ .probe("lua5.3");
}
lua.unwrap().include_paths[0].clone()
@@ -51,10 +62,13 @@ pub fn probe_lua() -> PathBuf {
{
let mut lua = pkg_config::Config::new()
.range_version((Bound::Included("5.2"), Bound::Excluded("5.3")))
+ .cargo_metadata(need_lua_lib)
.probe("lua");
if lua.is_err() {
- lua = pkg_config::Config::new().probe("lua5.2");
+ lua = pkg_config::Config::new()
+ .cargo_metadata(need_lua_lib)
+ .probe("lua5.2");
}
lua.unwrap().include_paths[0].clone()
@@ -64,10 +78,13 @@ pub fn probe_lua() -> PathBuf {
{
let mut lua = pkg_config::Config::new()
.range_version((Bound::Included("5.1"), Bound::Excluded("5.2")))
+ .cargo_metadata(need_lua_lib)
.probe("lua");
if lua.is_err() {
- lua = pkg_config::Config::new().probe("lua5.1");
+ lua = pkg_config::Config::new()
+ .cargo_metadata(need_lua_lib)
+ .probe("lua5.1");
}
lua.unwrap().include_paths[0].clone()
@@ -77,6 +94,7 @@ pub fn probe_lua() -> PathBuf {
{
let lua = pkg_config::Config::new()
.range_version((Bound::Included("2.0.5"), Bound::Unbounded))
+ .cargo_metadata(need_lua_lib)
.probe("luajit");
lua.unwrap().include_paths[0].clone()
@@ -104,15 +122,17 @@ fn use_custom_lua<S: AsRef<Path>>(include_dir: &S, lib_dir: &S, lua_lib: &S) ->
_ => "",
};
- println!(
- "cargo:rustc-link-search=native={}",
- lib_dir.as_ref().display()
- );
- println!(
- "cargo:rustc-link-lib={}{}",
- link_lib,
- lua_lib.as_ref().display()
- );
+ if cfg!(any(not(feature = "module"), target_os = "windows")) {
+ println!(
+ "cargo:rustc-link-search=native={}",
+ lib_dir.as_ref().display()
+ );
+ println!(
+ "cargo:rustc-link-lib={}{}",
+ link_lib,
+ lua_lib.as_ref().display()
+ );
+ }
Ok(version_found)
}