Skip to content

Commit 6622ab5

Browse files
committed
Add lua52compat feature flag
1 parent e9947c6 commit 6622ab5

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
- name: Run ${{ matrix.lua }} tests
8282
run: |
8383
cargo test --manifest-path testcrate/Cargo.toml --release
84+
cargo test --manifest-path testcrate/Cargo.toml --release --features lua52compat
8485
shell: bash
8586

8687
rustfmt:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ description = """
1111
Sources of LuaJIT 2.1 (OpenResty's branch) and logic to build it.
1212
"""
1313

14+
[features]
15+
lua52compat = []
16+
1417
[dependencies]
1518
cc = "1.0"

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ impl Build {
105105
make.env("CROSS", prefix);
106106
}
107107

108+
let mut xcflags = vec!["-fPIC"];
109+
if cfg!(feature = "lua52compat") {
110+
xcflags.push("-DLUAJIT_ENABLE_LUA52COMPAT");
111+
}
112+
108113
make.env("BUILDMODE", "static");
109-
make.env("XCFLAGS", "-fPIC");
114+
make.env("XCFLAGS", xcflags.join(" "));
110115
self.run_command(make, "building LuaJIT");
111116

112117
for f in &["lauxlib.h", "lua.h", "luaconf.h", "luajit.h", "lualib.h"] {

testcrate/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ name = "testcrate"
33
version = "0.1.0"
44
authors = ["Aleksandr Orlenko <[email protected]>"]
55

6+
[features]
7+
lua52compat = ["luajit-src/lua52compat"]
8+
69
[build-dependencies]
710
luajit-src = { path = ".." }

0 commit comments

Comments
 (0)