From 483e6be20705e315db5fc696c9bec1c0e8ce3486 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 18 Jul 2023 01:45:20 +0100 Subject: [PATCH] Support vendored module mode for windows (raw-dylib linking) This is requires Rust 1.71+ --- .github/workflows/main.yml | 4 ++++ mlua-sys/build/find_normal.rs | 2 ++ mlua-sys/build/find_vendored.rs | 2 ++ mlua-sys/build/main_inner.rs | 13 +++++------- mlua-sys/src/lua51/lauxlib.rs | 8 +++++++ mlua-sys/src/lua51/lua.rs | 16 ++++++++++++++ mlua-sys/src/lua51/lualib.rs | 4 ++++ mlua-sys/src/lua52/lauxlib.rs | 12 +++++++++++ mlua-sys/src/lua52/lua.rs | 33 +++++++++++++++++++++++++---- mlua-sys/src/lua52/lualib.rs | 4 ++++ mlua-sys/src/lua53/lauxlib.rs | 12 +++++++++++ mlua-sys/src/lua53/lua.rs | 33 +++++++++++++++++++++++++---- mlua-sys/src/lua53/lualib.rs | 4 ++++ mlua-sys/src/lua54/lauxlib.rs | 12 +++++++++++ mlua-sys/src/lua54/lua.rs | 37 +++++++++++++++++++++++++++++---- mlua-sys/src/lua54/lualib.rs | 4 ++++ tests/module/.cargo/config | 11 ---------- tests/module/Cargo.toml | 1 + tests/module/build.rs | 7 +++++++ 19 files changed, 188 insertions(+), 31 deletions(-) delete mode 100644 tests/module/.cargo/config create mode 100644 tests/module/build.rs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ac7aa8..aff3b16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -205,6 +205,10 @@ jobs: run: | (cd tests/module && cargo build --release --features "${{ matrix.lua }}") (cd tests/module/loader && cargo test --release --features "${{ matrix.lua }}") + - name: Run ${{ matrix.lua }} module tests (vendored) + run: | + (cd tests/module && cargo build --release --features "${{ matrix.lua }},vendored") + (cd tests/module/loader && cargo test --release --features "${{ matrix.lua }}") rustfmt: name: Rustfmt diff --git a/mlua-sys/build/find_normal.rs b/mlua-sys/build/find_normal.rs index c009d73..dd81c57 100644 --- a/mlua-sys/build/find_normal.rs +++ b/mlua-sys/build/find_normal.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::env; use std::ops::Bound; use std::path::PathBuf; diff --git a/mlua-sys/build/find_vendored.rs b/mlua-sys/build/find_vendored.rs index f7e33ab..0da3cee 100644 --- a/mlua-sys/build/find_vendored.rs +++ b/mlua-sys/build/find_vendored.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use std::path::PathBuf; pub fn probe_lua() -> Option { diff --git a/mlua-sys/build/main_inner.rs b/mlua-sys/build/main_inner.rs index 7d4f15f..29220bd 100644 --- a/mlua-sys/build/main_inner.rs +++ b/mlua-sys/build/main_inner.rs @@ -9,17 +9,14 @@ cfg_if::cfg_if! { } fn main() { - // We don't support "vendored module" mode on windows - #[cfg(all(feature = "vendored", feature = "module", target_os = "windows"))] - compile_error!( - "Vendored (static) builds are not supported for modules on Windows.\n" - + "Please, use `pkg-config` or custom mode to link to a Lua dll." - ); - #[cfg(all(feature = "luau", feature = "module"))] compile_error!("Luau does not support module mode"); - #[cfg(any(not(feature = "module"), target_os = "windows"))] + // "vendored, module" mode makes sense (only) on windows + #[cfg(any( + not(feature = "module"), + all(not(feature = "vendored"), target_os = "windows") + ))] find::probe_lua(); println!("cargo:rerun-if-changed=build"); diff --git a/mlua-sys/src/lua51/lauxlib.rs b/mlua-sys/src/lua51/lauxlib.rs index cdce05e..1388840 100644 --- a/mlua-sys/src/lua51/lauxlib.rs +++ b/mlua-sys/src/lua51/lauxlib.rs @@ -14,6 +14,10 @@ pub struct luaL_Reg { pub func: lua_CFunction, } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn luaL_register(L: *mut lua_State, libname: *const c_char, l: *const luaL_Reg); #[link_name = "luaL_getmetafield"] @@ -56,6 +60,10 @@ extern "C" { pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); diff --git a/mlua-sys/src/lua51/lua.rs b/mlua-sys/src/lua51/lua.rs index 5503b7f..9ca798c 100644 --- a/mlua-sys/src/lua51/lua.rs +++ b/mlua-sys/src/lua51/lua.rs @@ -89,6 +89,10 @@ pub type lua_Alloc = unsafe extern "C" fn( nsize: usize, ) -> *mut c_void; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { // // State manipulation @@ -221,6 +225,10 @@ pub const LUA_GCSTEP: c_int = 5; pub const LUA_GCSETPAUSE: c_int = 6; pub const LUA_GCSETSTEPMUL: c_int = 7; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } @@ -228,6 +236,10 @@ extern "C" { // // Miscellaneous functions // +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn lua_error(L: *mut lua_State) -> !; pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int; @@ -353,6 +365,10 @@ pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; diff --git a/mlua-sys/src/lua51/lualib.rs b/mlua-sys/src/lua51/lualib.rs index 2165221..b179695 100644 --- a/mlua-sys/src/lua51/lualib.rs +++ b/mlua-sys/src/lua51/lualib.rs @@ -20,6 +20,10 @@ pub const LUA_JITLIBNAME: &str = "jit"; #[cfg(feature = "luajit")] pub const LUA_FFILIBNAME: &str = "ffi"; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua51", kind = "raw-dylib") +)] extern "C" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua52/lauxlib.rs b/mlua-sys/src/lua52/lauxlib.rs index 6b16aeb..ac5a6d1 100644 --- a/mlua-sys/src/lua52/lauxlib.rs +++ b/mlua-sys/src/lua52/lauxlib.rs @@ -14,6 +14,10 @@ pub struct luaL_Reg { pub func: lua_CFunction, } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number); @@ -65,6 +69,10 @@ extern "C" { pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -78,6 +86,10 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { luaL_loadfilex(L, f, ptr::null()) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn luaL_loadbufferx( L: *mut lua_State, diff --git a/mlua-sys/src/lua52/lua.rs b/mlua-sys/src/lua52/lua.rs index 482e69f..4194a0d 100644 --- a/mlua-sys/src/lua52/lua.rs +++ b/mlua-sys/src/lua52/lua.rs @@ -94,6 +94,10 @@ pub type lua_Alloc = unsafe extern "C" fn( nsize: usize, ) -> *mut c_void; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { // // State manipulation @@ -155,19 +159,24 @@ pub const LUA_OPMOD: c_int = 4; pub const LUA_OPPOW: c_int = 5; pub const LUA_OPUNM: c_int = 6; -extern "C" { - pub fn lua_arith(L: *mut lua_State, op: c_int); -} - pub const LUA_OPEQ: c_int = 0; pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { + pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { // // Push functions (C -> stack) @@ -262,6 +271,10 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in lua_pcallk(L, n, r, f, 0, None) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { // // Coroutine functions @@ -298,10 +311,18 @@ pub const LUA_GCISRUNNING: c_int = 9; pub const LUA_GCGEN: c_int = 10; pub const LUA_GCINC: c_int = 11; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { // // Miscellaneous functions @@ -439,6 +460,10 @@ pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; diff --git a/mlua-sys/src/lua52/lualib.rs b/mlua-sys/src/lua52/lualib.rs index 9ffba45..3c79c7f 100644 --- a/mlua-sys/src/lua52/lualib.rs +++ b/mlua-sys/src/lua52/lualib.rs @@ -14,6 +14,10 @@ pub const LUA_MATHLIBNAME: &str = "math"; pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua52", kind = "raw-dylib") +)] extern "C" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua53/lauxlib.rs b/mlua-sys/src/lua53/lauxlib.rs index 0d1679f..40a0655 100644 --- a/mlua-sys/src/lua53/lauxlib.rs +++ b/mlua-sys/src/lua53/lauxlib.rs @@ -20,6 +20,10 @@ pub struct luaL_Reg { pub func: lua_CFunction, } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize); @@ -67,6 +71,10 @@ extern "C" { pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -80,6 +88,10 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { luaL_loadfilex(L, f, ptr::null()) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { pub fn luaL_loadbufferx( L: *mut lua_State, diff --git a/mlua-sys/src/lua53/lua.rs b/mlua-sys/src/lua53/lua.rs index c0127bb..a76fd25 100644 --- a/mlua-sys/src/lua53/lua.rs +++ b/mlua-sys/src/lua53/lua.rs @@ -102,6 +102,10 @@ pub type lua_Alloc = unsafe extern "C" fn( nsize: usize, ) -> *mut c_void; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { // // State manipulation @@ -167,19 +171,24 @@ pub const LUA_OPSHR: c_int = 11; pub const LUA_OPUNM: c_int = 12; pub const LUA_OPBNOT: c_int = 13; -extern "C" { - pub fn lua_arith(L: *mut lua_State, op: c_int); -} - pub const LUA_OPEQ: c_int = 0; pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { + pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { // // Push functions (C -> stack) @@ -270,6 +279,10 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in lua_pcallk(L, n, r, f, 0, None) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { // // Coroutine functions @@ -304,10 +317,18 @@ pub const LUA_GCSETPAUSE: c_int = 6; pub const LUA_GCSETSTEPMUL: c_int = 7; pub const LUA_GCISRUNNING: c_int = 9; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { // // Miscellaneous functions @@ -463,6 +484,10 @@ pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; diff --git a/mlua-sys/src/lua53/lualib.rs b/mlua-sys/src/lua53/lualib.rs index 1cedf75..c70867a 100644 --- a/mlua-sys/src/lua53/lualib.rs +++ b/mlua-sys/src/lua53/lualib.rs @@ -15,6 +15,10 @@ pub const LUA_MATHLIBNAME: &str = "math"; pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua53", kind = "raw-dylib") +)] extern "C" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua54/lauxlib.rs b/mlua-sys/src/lua54/lauxlib.rs index 5a6c173..7a97365 100644 --- a/mlua-sys/src/lua54/lauxlib.rs +++ b/mlua-sys/src/lua54/lauxlib.rs @@ -20,6 +20,10 @@ pub struct luaL_Reg { pub func: lua_CFunction, } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize); @@ -66,6 +70,10 @@ extern "C" { pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -79,6 +87,10 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { luaL_loadfilex(L, f, ptr::null()) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn luaL_loadbufferx( L: *mut lua_State, diff --git a/mlua-sys/src/lua54/lua.rs b/mlua-sys/src/lua54/lua.rs index 218255e..605ac30 100644 --- a/mlua-sys/src/lua54/lua.rs +++ b/mlua-sys/src/lua54/lua.rs @@ -105,6 +105,10 @@ pub type lua_Alloc = unsafe extern "C" fn( pub type lua_WarnFunction = unsafe extern "C" fn(ud: *mut c_void, msg: *const c_char, tocont: c_int); +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { // // State manipulation @@ -174,19 +178,24 @@ pub const LUA_OPSHR: c_int = 11; pub const LUA_OPUNM: c_int = 12; pub const LUA_OPBNOT: c_int = 13; -extern "C" { - pub fn lua_arith(L: *mut lua_State, op: c_int); -} - pub const LUA_OPEQ: c_int = 0; pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { + pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { // // Push functions (C -> stack) @@ -277,6 +286,10 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in lua_pcallk(L, n, r, f, 0, None) } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { // // Coroutine functions @@ -305,6 +318,10 @@ pub unsafe fn lua_yield(L: *mut lua_State, n: c_int) -> c_int { // // Warning-related functions // +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn lua_setwarnf(L: *mut lua_State, f: Option, ud: *mut c_void); pub fn lua_warning(L: *mut lua_State, msg: *const c_char, tocont: c_int); @@ -325,10 +342,18 @@ pub const LUA_GCISRUNNING: c_int = 9; pub const LUA_GCGEN: c_int = 10; pub const LUA_GCINC: c_int = 11; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn lua_gc(L: *mut lua_State, what: c_int, ...) -> c_int; } +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { // // Miscellaneous functions @@ -502,6 +527,10 @@ pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; diff --git a/mlua-sys/src/lua54/lualib.rs b/mlua-sys/src/lua54/lualib.rs index 3626004..e9fd29b 100644 --- a/mlua-sys/src/lua54/lualib.rs +++ b/mlua-sys/src/lua54/lualib.rs @@ -14,6 +14,10 @@ pub const LUA_MATHLIBNAME: &str = "math"; pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; +#[cfg_attr( + all(windows, feature = "module", feature = "vendored"), + link(name = "lua54", kind = "raw-dylib") +)] extern "C" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; diff --git a/tests/module/.cargo/config b/tests/module/.cargo/config deleted file mode 100644 index d47f983..0000000 --- a/tests/module/.cargo/config +++ /dev/null @@ -1,11 +0,0 @@ -[target.x86_64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] - -[target.aarch64-apple-darwin] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/tests/module/Cargo.toml b/tests/module/Cargo.toml index c2e0da8..c7b843c 100644 --- a/tests/module/Cargo.toml +++ b/tests/module/Cargo.toml @@ -18,6 +18,7 @@ lua53 = ["mlua/lua53"] lua52 = ["mlua/lua52"] lua51 = ["mlua/lua51"] luajit = ["mlua/luajit"] +vendored = ["mlua/vendored"] [dependencies] mlua = { path = "../..", features = ["module"] } diff --git a/tests/module/build.rs b/tests/module/build.rs new file mode 100644 index 0000000..eb5ca3c --- /dev/null +++ b/tests/module/build.rs @@ -0,0 +1,7 @@ +fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-cdylib-link-arg=-undefined"); + println!("cargo:rustc-cdylib-link-arg=dynamic_lookup"); + } +}