Make the builtin version of lua 5.3 optional

In case you would need to build a crazy custom version of lua for a weird
platform.  This could possibly be done in a cleaner way.
This commit is contained in:
kyren 2017-07-05 19:35:53 -04:00
parent 6b8a4240e2
commit b8fab1b3ed
2 changed files with 67 additions and 55 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "rlua"
version = "0.8.0"
version = "0.8.1"
authors = ["kyren <catherine@chucklefish.org>"]
description = "High level bindings to Lua 5.3"
repository = "https://github.com/chucklefish/rlua"
@ -9,8 +9,17 @@ readme = "README.md"
keywords = ["lua"]
license = "MIT"
[features]
default = ["builtin-lua"]
# Builds the correct version of Lua 5.3 inside the crate. If you want to link a
# specialized version of lua into your binary, you can disable this feature to
# do that, but care must be taken. `rlua` expects the linked lua to define
# LUA_INTEGER as long long, and LUA_NUMBER as double, and may make other
# assumptions about how lua is built.
builtin-lua = ["gcc"]
[build-dependencies]
gcc = "0.3"
gcc = { version = "0.3", optional = true }
[dependencies]
hlist-macro = "0.1"

109
build.rs
View file

@ -3,60 +3,63 @@ extern crate gcc;
use std::env;
fn main() {
let mut config = gcc::Config::new();
#[cfg(feature = "builtin-lua")]
{
let mut config = gcc::Config::new();
let target_os = env::var("CARGO_CFG_TARGET_OS");
let target_family = env::var("CARGO_CFG_TARGET_FAMILY");
let target_os = env::var("CARGO_CFG_TARGET_OS");
let target_family = env::var("CARGO_CFG_TARGET_FAMILY");
if target_os == Ok("linux".to_string()) {
config.define("LUA_USE_LINUX", None);
} else if target_os == Ok("macos".to_string()) {
config.define("LUA_USE_MACOSX", None);
} else if target_family == Ok("unix".to_string()) {
config.define("LUA_USE_POSIX", None);
} else if target_family == Ok("windows".to_string()) {
config.define("LUA_USE_WINDOWS", None);
if target_os == Ok("linux".to_string()) {
config.define("LUA_USE_LINUX", None);
} else if target_os == Ok("macos".to_string()) {
config.define("LUA_USE_MACOSX", None);
} else if target_family == Ok("unix".to_string()) {
config.define("LUA_USE_POSIX", None);
} else if target_family == Ok("windows".to_string()) {
config.define("LUA_USE_WINDOWS", None);
}
// Enables lua api checking, which has a slight performance penalty. We
// could allow disabling this via cfg one day when there is much more
// confidence in the soundness of the API.
config.define("LUA_USE_APICHECK", None);
config
.include("lua")
.file("lua/lapi.c")
.file("lua/lauxlib.c")
.file("lua/lbaselib.c")
.file("lua/lbitlib.c")
.file("lua/lcode.c")
.file("lua/lcorolib.c")
.file("lua/lctype.c")
.file("lua/ldblib.c")
.file("lua/ldebug.c")
.file("lua/ldo.c")
.file("lua/ldump.c")
.file("lua/lfunc.c")
.file("lua/lgc.c")
.file("lua/linit.c")
.file("lua/liolib.c")
.file("lua/llex.c")
.file("lua/lmathlib.c")
.file("lua/lmem.c")
.file("lua/loadlib.c")
.file("lua/lobject.c")
.file("lua/lopcodes.c")
.file("lua/loslib.c")
.file("lua/lparser.c")
.file("lua/lstate.c")
.file("lua/lstring.c")
.file("lua/lstrlib.c")
.file("lua/ltable.c")
.file("lua/ltablib.c")
.file("lua/ltm.c")
.file("lua/lundump.c")
.file("lua/lutf8lib.c")
.file("lua/lvm.c")
.file("lua/lzio.c")
.compile("liblua.a");
}
// Enables lua api checking, which has a slight performance penalty. We
// could allow disabling this via cfg one day when there is much more
// confidence in the soundness of the API.
config.define("LUA_USE_APICHECK", None);
config
.include("lua")
.file("lua/lapi.c")
.file("lua/lauxlib.c")
.file("lua/lbaselib.c")
.file("lua/lbitlib.c")
.file("lua/lcode.c")
.file("lua/lcorolib.c")
.file("lua/lctype.c")
.file("lua/ldblib.c")
.file("lua/ldebug.c")
.file("lua/ldo.c")
.file("lua/ldump.c")
.file("lua/lfunc.c")
.file("lua/lgc.c")
.file("lua/linit.c")
.file("lua/liolib.c")
.file("lua/llex.c")
.file("lua/lmathlib.c")
.file("lua/lmem.c")
.file("lua/loadlib.c")
.file("lua/lobject.c")
.file("lua/lopcodes.c")
.file("lua/loslib.c")
.file("lua/lparser.c")
.file("lua/lstate.c")
.file("lua/lstring.c")
.file("lua/lstrlib.c")
.file("lua/ltable.c")
.file("lua/ltablib.c")
.file("lua/ltm.c")
.file("lua/lundump.c")
.file("lua/lutf8lib.c")
.file("lua/lvm.c")
.file("lua/lzio.c")
.compile("liblua.a");
}