Remove unused exports from glue.{c,rs} && Fix some clippy warnings
This commit is contained in:
parent
1c79f646de
commit
e62fd400d7
|
@ -1,7 +1,8 @@
|
||||||
#![allow(unreachable_code)]
|
#![allow(unreachable_code)]
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::{Error, ErrorKind, Result};
|
use std::fs::File;
|
||||||
|
use std::io::{Error, ErrorKind, Result, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
@ -96,51 +97,36 @@ fn build_glue<P: AsRef<Path> + std::fmt::Debug>(include_path: &P) {
|
||||||
// If you're cross-compiling and using a non-vendored library then there is a chance
|
// If you're cross-compiling and using a non-vendored library then there is a chance
|
||||||
// that the values selected here may be incorrect, but we have no way to determine
|
// that the values selected here may be incorrect, but we have no way to determine
|
||||||
// that here.
|
// that here.
|
||||||
fn generate_glue() -> std::io::Result<()> {
|
fn generate_glue() -> Result<()> {
|
||||||
use std::io::Write;
|
|
||||||
let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
let mut glue = std::fs::File::create(build_dir.join("glue.rs"))?;
|
let mut glue = File::create(build_dir.join("glue.rs"))?;
|
||||||
write!(
|
writeln!(
|
||||||
glue,
|
glue,
|
||||||
"/* This file was generated by build/main.rs; do not modify by hand */\n"
|
"/* This file was generated by build/main.rs; do not modify by hand */"
|
||||||
)?;
|
)?;
|
||||||
write!(glue, "use std::os::raw::*;\n")?;
|
writeln!(glue, "use std::os::raw::*;")?;
|
||||||
|
|
||||||
// We can't statically determine the default paths.
|
|
||||||
// It is possible though to use something like lazy_static! to create a new
|
|
||||||
// lua context and extract that information.
|
|
||||||
// For my (@wez) purposes, I actually don't want there to be a default path,
|
|
||||||
// so I'm just leaving this blank for the moment.
|
|
||||||
write!(glue, "pub const LUA_PATH_DEFAULT: &str = \"\";\n")?;
|
|
||||||
write!(glue, "pub const LUA_CPATH_DEFAULT: &str = \"\";\n")?;
|
|
||||||
|
|
||||||
write!(
|
|
||||||
glue,
|
|
||||||
"#[cfg(windows)] pub const LUA_DIRSEP: &str = \"\\\\\";\n"
|
|
||||||
)?;
|
|
||||||
write!(glue, "#[cfg(unix)] pub const LUA_DIRSEP: &str = \"/\";\n")?;
|
|
||||||
|
|
||||||
|
writeln!(glue, "/* luaconf.h */")?;
|
||||||
let pointer_bit_width: usize = env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
|
let pointer_bit_width: usize = env::var("CARGO_CFG_TARGET_POINTER_WIDTH")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
write!(
|
writeln!(
|
||||||
glue,
|
glue,
|
||||||
"pub const LUA_EXTRASPACE: c_int = {} / 8;\n",
|
"pub const LUA_EXTRASPACE: c_int = {} / 8;",
|
||||||
pointer_bit_width
|
pointer_bit_width
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// This is generally hardcoded to this size
|
// This is generally hardcoded to this size
|
||||||
write!(glue, "pub const LUA_IDSIZE: c_int = 60;\n")?;
|
writeln!(glue, "pub const LUA_IDSIZE: c_int = 60;")?;
|
||||||
|
|
||||||
write!(glue, "pub const LUAL_BUFFERSIZE: c_int = 16 * ({} / 8) * std::mem::size_of::<LUA_NUMBER>() as c_int;\n", pointer_bit_width)?;
|
|
||||||
|
|
||||||
// Unless the target is restricted, the defaults are 64 bit
|
// Unless the target is restricted, the defaults are 64 bit
|
||||||
write!(glue, "pub type LUA_NUMBER = c_double;\n")?;
|
writeln!(glue, "pub type LUA_NUMBER = c_double;")?;
|
||||||
write!(glue, "pub type LUA_INTEGER = i64;\n")?;
|
writeln!(glue, "pub type LUA_INTEGER = i64;")?;
|
||||||
write!(glue, "pub type LUA_UNSIGNED = u64;\n")?;
|
writeln!(glue, "pub type LUA_UNSIGNED = u64;")?;
|
||||||
|
|
||||||
let version = if cfg!(feature = "luajit") || cfg!(feature = "lua51") {
|
writeln!(glue, "/* lua.h */")?;
|
||||||
|
let version = if cfg!(any(feature = "luajit", feature = "lua51")) {
|
||||||
(5, 1, 0)
|
(5, 1, 0)
|
||||||
} else if cfg!(feature = "lua52") {
|
} else if cfg!(feature = "lua52") {
|
||||||
(5, 2, 0)
|
(5, 2, 0)
|
||||||
|
@ -151,43 +137,34 @@ fn generate_glue() -> std::io::Result<()> {
|
||||||
} else {
|
} else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
|
writeln!(
|
||||||
write!(
|
|
||||||
glue,
|
glue,
|
||||||
"pub const LUA_VERSION_NUM: c_int = {};\n",
|
"pub const LUA_VERSION_NUM: c_int = {};",
|
||||||
(version.0 * 100) + version.1
|
(version.0 * 100) + version.1
|
||||||
)?;
|
)?;
|
||||||
write!(
|
|
||||||
glue,
|
|
||||||
"pub const LUA_VERSION: &str = \"Lua {}.{}\";\n",
|
|
||||||
version.0, version.1
|
|
||||||
)?;
|
|
||||||
write!(
|
|
||||||
glue,
|
|
||||||
"pub const LUA_RELEASE: &str = \"Lua {}.{}.{}\";\n",
|
|
||||||
version.0, version.1, version.2
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let max_stack = if pointer_bit_width >= 32 {
|
let max_stack = if pointer_bit_width >= 32 {
|
||||||
1_000_000
|
1_000_000
|
||||||
} else {
|
} else {
|
||||||
15_000
|
15_000
|
||||||
};
|
};
|
||||||
write!(
|
writeln!(
|
||||||
glue,
|
glue,
|
||||||
"pub const LUA_REGISTRYINDEX: c_int = -{} - 1000;\n",
|
"pub const LUA_REGISTRYINDEX: c_int = -{} - 1000;",
|
||||||
max_stack
|
max_stack
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// These two are only defined in lua 5.1
|
// These two are only defined in lua 5.1
|
||||||
write!(glue, "pub const LUA_ENVIRONINDEX: c_int = -10001;\n")?;
|
writeln!(glue, "pub const LUA_ENVIRONINDEX: c_int = -10001;")?;
|
||||||
write!(glue, "pub const LUA_GLOBALSINDEX: c_int = -10002;\n")?;
|
writeln!(glue, "pub const LUA_GLOBALSINDEX: c_int = -10002;")?;
|
||||||
|
|
||||||
|
writeln!(glue, "/* lauxlib.h */")?;
|
||||||
// This is only defined in lua 5.3 and up, but we can always generate its value here,
|
// This is only defined in lua 5.3 and up, but we can always generate its value here,
|
||||||
// even if we don't use it.
|
// even if we don't use it.
|
||||||
// This matches the default definition in lauxlib.h
|
// This matches the default definition in lauxlib.h
|
||||||
write!(glue, "pub const LUAL_NUMSIZES: c_int = std::mem::size_of::<LUA_INTEGER>() as c_int * 16 + std::mem::size_of::<LUA_NUMBER>() as c_int;\n")?;
|
writeln!(glue, "pub const LUAL_NUMSIZES: c_int = std::mem::size_of::<LUA_INTEGER>() as c_int * 16 + std::mem::size_of::<LUA_NUMBER>() as c_int;")?;
|
||||||
|
|
||||||
|
writeln!(glue, "/* lualib.h */")?;
|
||||||
write!(
|
write!(
|
||||||
glue,
|
glue,
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -225,12 +225,8 @@ int main(int argc, const char **argv) {
|
||||||
// == luaconf.h ==========================================================
|
// == luaconf.h ==========================================================
|
||||||
|
|
||||||
RS_COMMENT("luaconf.h"),
|
RS_COMMENT("luaconf.h"),
|
||||||
RS_STR("LUA_PATH_DEFAULT", LUA_PATH_DEFAULT),
|
|
||||||
RS_STR("LUA_CPATH_DEFAULT", LUA_CPATH_DEFAULT),
|
|
||||||
RS_STR("LUA_DIRSEP", LUA_DIRSEP),
|
|
||||||
RS_INT("LUA_EXTRASPACE", LUA_EXTRASPACE),
|
RS_INT("LUA_EXTRASPACE", LUA_EXTRASPACE),
|
||||||
RS_INT("LUA_IDSIZE", LUA_IDSIZE),
|
RS_INT("LUA_IDSIZE", LUA_IDSIZE),
|
||||||
RS_INT("LUAL_BUFFERSIZE", LUAL_BUFFERSIZE),
|
|
||||||
RS_TYPE("LUA_NUMBER",
|
RS_TYPE("LUA_NUMBER",
|
||||||
sizeof(LUA_NUMBER) > sizeof(float) ? "c_double" : "c_float"),
|
sizeof(LUA_NUMBER) > sizeof(float) ? "c_double" : "c_float"),
|
||||||
RS_TYPE("LUA_INTEGER", rs_int_type(sizeof(LUA_INTEGER))),
|
RS_TYPE("LUA_INTEGER", rs_int_type(sizeof(LUA_INTEGER))),
|
||||||
|
@ -244,8 +240,6 @@ int main(int argc, const char **argv) {
|
||||||
|
|
||||||
RS_COMMENT("lua.h"),
|
RS_COMMENT("lua.h"),
|
||||||
RS_INT("LUA_VERSION_NUM", LUA_VERSION_NUM),
|
RS_INT("LUA_VERSION_NUM", LUA_VERSION_NUM),
|
||||||
RS_STR("LUA_VERSION", LUA_VERSION),
|
|
||||||
RS_STR("LUA_RELEASE", LUA_RELEASE),
|
|
||||||
RS_INT("LUA_REGISTRYINDEX", LUA_REGISTRYINDEX),
|
RS_INT("LUA_REGISTRYINDEX", LUA_REGISTRYINDEX),
|
||||||
#if LUA_VERSION_NUM == 501
|
#if LUA_VERSION_NUM == 501
|
||||||
RS_INT("LUA_ENVIRONINDEX", LUA_ENVIRONINDEX),
|
RS_INT("LUA_ENVIRONINDEX", LUA_ENVIRONINDEX),
|
||||||
|
|
|
@ -32,11 +32,9 @@ use std::ptr;
|
||||||
|
|
||||||
use super::luaconf;
|
use super::luaconf;
|
||||||
|
|
||||||
pub use super::glue::{LUA_RELEASE, LUA_VERSION, LUA_VERSION_NUM};
|
|
||||||
|
|
||||||
pub use super::glue::LUA_REGISTRYINDEX;
|
|
||||||
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
#[cfg(any(feature = "lua51", feature = "luajit"))]
|
||||||
pub use super::glue::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX};
|
pub use super::glue::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX};
|
||||||
|
pub use super::glue::{LUA_REGISTRYINDEX, LUA_VERSION_NUM};
|
||||||
|
|
||||||
#[cfg(not(feature = "luajit"))]
|
#[cfg(not(feature = "luajit"))]
|
||||||
pub const LUA_SIGNATURE: &[u8] = b"\x1bLua";
|
pub const LUA_SIGNATURE: &[u8] = b"\x1bLua";
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
//! Contains definitions from `luaconf.h`.
|
//! Contains definitions from `luaconf.h`.
|
||||||
|
|
||||||
pub use super::glue::LUAL_BUFFERSIZE;
|
|
||||||
pub use super::glue::LUA_INTEGER;
|
pub use super::glue::LUA_INTEGER;
|
||||||
pub use super::glue::LUA_NUMBER;
|
pub use super::glue::LUA_NUMBER;
|
||||||
pub use super::glue::LUA_UNSIGNED;
|
pub use super::glue::LUA_UNSIGNED;
|
||||||
|
|
Loading…
Reference in New Issue