diff options
| author | ruki <[email protected]> | 2022-12-15 00:32:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-12-15 00:32:48 +0800 |
| commit | f12120f9b0d6118df89b50217350d26ed9398496 (patch) | |
| tree | 44b497b552240f47dc2e6d61c6276832afeec485 /core/src | |
| parent | 3574928f7cbcdfc722c4ab35a9c0d4bf10935ec7 (diff) | |
improve xmake.sh for lua
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/lua-cjson/xmake.lua | 2 | ||||
| -rwxr-xr-x | core/src/lua-cjson/xmake.sh | 6 | ||||
| -rw-r--r-- | core/src/lua/xmake.lua | 3 | ||||
| -rwxr-xr-x | core/src/lua/xmake.sh | 3 | ||||
| -rw-r--r-- | core/src/luajit/xmake.lua | 5 | ||||
| -rwxr-xr-x | core/src/luajit/xmake.sh | 67 | ||||
| -rw-r--r-- | core/src/xmake/xmake.lua | 5 | ||||
| -rwxr-xr-x | core/src/xmake/xmake.sh | 7 |
8 files changed, 72 insertions, 26 deletions
diff --git a/core/src/lua-cjson/xmake.lua b/core/src/lua-cjson/xmake.lua index 75b62c16b..74406d67e 100644 --- a/core/src/lua-cjson/xmake.lua +++ b/core/src/lua-cjson/xmake.lua @@ -1,7 +1,7 @@ target("lua-cjson") set_kind("static") set_warnings("all") - add_deps(get_config("runtime")) + add_deps("lua") if is_plat("windows") then set_languages("c89") end diff --git a/core/src/lua-cjson/xmake.sh b/core/src/lua-cjson/xmake.sh index c39903d35..6b9e4aad3 100755 --- a/core/src/lua-cjson/xmake.sh +++ b/core/src/lua-cjson/xmake.sh @@ -3,11 +3,7 @@ target "lua_cjson" set_kind "static" set_warnings "all" - if is_config "runtime" "luajit"; then - add_deps "luajit" - else - add_deps "lua" - fi + add_deps "lua" add_files "lua-cjson/dtoa.c" add_files "lua-cjson/lua_cjson.c" add_files "lua-cjson/strbuf.c" diff --git a/core/src/lua/xmake.lua b/core/src/lua/xmake.lua index 5d08083db..048d7305e 100644 --- a/core/src/lua/xmake.lua +++ b/core/src/lua/xmake.lua @@ -1,7 +1,4 @@ target("lua") - if not is_config("runtime", "lua") then - set_default(false) - end set_kind("static") set_warnings("all") diff --git a/core/src/lua/xmake.sh b/core/src/lua/xmake.sh index fd5fbac40..f9e190c16 100755 --- a/core/src/lua/xmake.sh +++ b/core/src/lua/xmake.sh @@ -1,9 +1,6 @@ #!/bin/sh target "lua" - if ! is_config "runtime" "lua"; then - set_default false - fi set_kind "static" set_warnings "all" diff --git a/core/src/luajit/xmake.lua b/core/src/luajit/xmake.lua index 427c319a1..8ad0bf1af 100644 --- a/core/src/luajit/xmake.lua +++ b/core/src/luajit/xmake.lua @@ -22,10 +22,7 @@ end local autogendir = path.join("luajit", "autogen", plat, jit and "jit" or "nojit", arch) -- add target -target("luajit") - if not is_config("runtime", "luajit") then - set_default(false) - end +target("lua") -- make as a static library set_kind("static") diff --git a/core/src/luajit/xmake.sh b/core/src/luajit/xmake.sh new file mode 100755 index 000000000..e9a4222b0 --- /dev/null +++ b/core/src/luajit/xmake.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# disable jit compiler for redhat and centos +jit=true +jit_plat="${plat}" +jit_arch="${arch}" +if is_plat "mingw"; then + jit_plat="windows" + if is_arch "x86_64"; then + jit_arch="x64" + else + jit_arch="x86" + fi +fi +if is_arch "arm64" "arm64-v8a"; then + jit_arch="arm64" +elif is_arch "arm" "armv7"; then + jit_arch="arm" +elif is_arch "mips64"; then + jit_arch="mips64" + jit=false +fi +if test -f "/etc/redhat-release"; then + jit=false +fi +if $jit; then + jit_dir="jit" +else + jit_dir="nojit" +fi +jit_autogendir="luajit/autogen/${jit_plat}/${jit_dir}/${jit_arch}" + +target "lua" + set_kind "static" + set_warnings "all" + + # add include directories + add_includedirs "${jit_autogendir}" + add_includedirs "luajit/src" "{public}" + + # add the common source files + add_files "luajit/src/lj_*.c" + add_files "luajit/src/lib_*.c" + if is_plat "mingw"; then + add_files "${jit_autogendir}/lj_vm.o" + else + add_files "${jit_autogendir}/*.S" + fi + + add_defines "USE_LUAJIT" "{public}" + + # disable jit compiler? + if ! $jit; then + add_defines "LUAJIT_DISABLE_JIT" + fi + + # using internal memory management under armv7 gc will cause a crash when free strings in lua_close + if test_eq "${jit_arch}" "arm"; then + add_defines "LUAJIT_USE_SYSMALLOC" + fi + + # fix call math.sin/log crash for fedora/i386/lj_vm.S with `LDFLAGS = -specs=/usr/lib/rpm/redhat/redhat-hardened-ld` in xmake.spec/%set_build_flags + if is_plat "linux" && is_arch "i386"; then + add_asflags "-fPIE" + add_ldflags "-fPIE" + fi + diff --git a/core/src/xmake/xmake.lua b/core/src/xmake/xmake.lua index 1745313fa..e100832ba 100644 --- a/core/src/xmake/xmake.lua +++ b/core/src/xmake/xmake.lua @@ -1,11 +1,8 @@ target("xmake") - - -- make as a static library set_kind("static") -- add deps - add_deps("sv", "lua-cjson", "lz4", "tbox") - add_deps(get_config("runtime")) + add_deps("sv", "lua-cjson", "lua", "lz4", "tbox") if is_plat("windows") and has_config("pdcurses") then add_deps("pdcurses") end diff --git a/core/src/xmake/xmake.sh b/core/src/xmake/xmake.sh index 7bb0b9d31..29cb102ba 100755 --- a/core/src/xmake/xmake.sh +++ b/core/src/xmake/xmake.sh @@ -4,12 +4,7 @@ target "xmake" set_kind "static" # add deps - add_deps "sv" "lua_cjson" "lz4" "tbox" - if is_config "runtime" "luajit"; then - add_deps "luajit" - else - add_deps "lua" - fi + add_deps "sv" "lua_cjson" "lua" "lz4" "tbox" # add defines add_defines "__tb_prefix__=\"xmake\"" |
