New build options: max_cstack_size and use_longjmp
This commit is contained in:
parent
3bfe1afb96
commit
8e13672c05
26
src/lib.rs
26
src/lib.rs
|
@ -6,6 +6,10 @@ pub struct Build {
|
||||||
out_dir: Option<PathBuf>,
|
out_dir: Option<PathBuf>,
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
host: Option<String>,
|
host: Option<String>,
|
||||||
|
// Max number of Lua stack slots that a C function can use
|
||||||
|
max_cstack_size: usize,
|
||||||
|
// Use longjmp instead of C++ exceptions
|
||||||
|
use_longjmp: bool,
|
||||||
// Enable code generator (jit)
|
// Enable code generator (jit)
|
||||||
enable_codegen: bool,
|
enable_codegen: bool,
|
||||||
}
|
}
|
||||||
|
@ -24,6 +28,8 @@ impl Build {
|
||||||
out_dir: env::var_os("OUT_DIR").map(|s| PathBuf::from(s).join("luau-build")),
|
out_dir: env::var_os("OUT_DIR").map(|s| PathBuf::from(s).join("luau-build")),
|
||||||
target: env::var("TARGET").ok(),
|
target: env::var("TARGET").ok(),
|
||||||
host: env::var("HOST").ok(),
|
host: env::var("HOST").ok(),
|
||||||
|
max_cstack_size: 100000,
|
||||||
|
use_longjmp: false,
|
||||||
enable_codegen: false,
|
enable_codegen: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +49,16 @@ impl Build {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_max_cstack_size(&mut self, size: usize) -> &mut Build {
|
||||||
|
self.max_cstack_size = size;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn use_longjmp(&mut self, r#use: bool) -> &mut Build {
|
||||||
|
self.use_longjmp = r#use;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn enable_codegen(&mut self, enable: bool) -> &mut Build {
|
pub fn enable_codegen(&mut self, enable: bool) -> &mut Build {
|
||||||
self.enable_codegen = enable;
|
self.enable_codegen = enable;
|
||||||
self
|
self
|
||||||
|
@ -91,6 +107,13 @@ impl Build {
|
||||||
.flag_if_supported("/std:c++17") // MSVC
|
.flag_if_supported("/std:c++17") // MSVC
|
||||||
.cpp(true);
|
.cpp(true);
|
||||||
|
|
||||||
|
// Common defines
|
||||||
|
config.define("LUAI_MAXCSTACK", &*self.max_cstack_size.to_string());
|
||||||
|
|
||||||
|
if self.use_longjmp {
|
||||||
|
config.define("LUA_USE_LONGJMP", "1");
|
||||||
|
}
|
||||||
|
|
||||||
if self.enable_codegen {
|
if self.enable_codegen {
|
||||||
config.define("LUA_CUSTOM_EXECUTION", None);
|
config.define("LUA_CUSTOM_EXECUTION", None);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +147,6 @@ impl Build {
|
||||||
.define("LUACODEGEN_API", "extern \"C\"")
|
.define("LUACODEGEN_API", "extern \"C\"")
|
||||||
// Code generator uses lua VM internals, so we need to provide the same defines used to build VM
|
// Code generator uses lua VM internals, so we need to provide the same defines used to build VM
|
||||||
.define("LUA_API", "extern \"C\"")
|
.define("LUA_API", "extern \"C\"")
|
||||||
.define("LUAI_MAXCSTACK", "100000")
|
|
||||||
.add_files_by_ext(&codegen_source_dir, "cpp")
|
.add_files_by_ext(&codegen_source_dir, "cpp")
|
||||||
.out_dir(&lib_dir)
|
.out_dir(&lib_dir)
|
||||||
.compile(codegen_lib_name);
|
.compile(codegen_lib_name);
|
||||||
|
@ -149,8 +171,6 @@ impl Build {
|
||||||
.include(&vm_include_dir)
|
.include(&vm_include_dir)
|
||||||
.include(&common_include_dir)
|
.include(&common_include_dir)
|
||||||
.define("LUA_API", "extern \"C\"")
|
.define("LUA_API", "extern \"C\"")
|
||||||
.define("LUAI_MAXCSTACK", "100000")
|
|
||||||
// .define("LUA_USE_LONGJMP", "1")
|
|
||||||
.add_files_by_ext(&vm_source_dir, "cpp")
|
.add_files_by_ext(&vm_source_dir, "cpp")
|
||||||
.out_dir(&lib_dir)
|
.out_dir(&lib_dir)
|
||||||
.compile(vm_lib_name);
|
.compile(vm_lib_name);
|
||||||
|
|
Loading…
Reference in New Issue