From 6f9926b5829cb114e193d993d98bb75314efbbb5 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Mon, 22 Mar 2021 08:51:26 +0100 Subject: [PATCH] Add flags to run both luajit and lua --- build-packages.sh | 13 ++++++++++--- data/core/compat.lua | 12 ++++++++---- meson.build | 3 ++- src/api/compat.c | 4 +++- src/api/compat.h | 3 +++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/build-packages.sh b/build-packages.sh index e9e952d3..6b82bb46 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -62,9 +62,11 @@ lite_build_package_windows () { if [ "$portable" == "-portable" ]; then local bindir="$pdir" local datadir="$pdir/data" + local suffix="" else local bindir="$pdir/bin" local datadir="$pdir/share/lite-xl" + local suffix="-msys" fi mkdir -p "$bindir" mkdir -p "$datadir" @@ -77,7 +79,7 @@ lite_build_package_windows () { cp "$build/src/lite.exe" "$bindir" strip --strip-all "$bindir/lite.exe" pushd ".package-build" - local package_name="lite-xl-$os-$arch$portable.zip" + local package_name="lite-xl-$os-$arch$suffix.zip" zip "$package_name" -r "lite-xl" mv "$package_name" .. popd @@ -188,7 +190,12 @@ lite_build_package () { lite_copy_third_party_modules () { local build="$1" - curl --insecure -L "https://github.com/rxi/lite-colors/archive/master.zip" -o "$build/rxi-lite-colors.zip" + for count in 1 2 3 4 5; do + curl --insecure -L "https://github.com/rxi/lite-colors/archive/master.zip" -o "$build/rxi-lite-colors.zip" + if [ $? -eq 0 ]; then + break + fi + done mkdir -p "$build/third/data/colors" "$build/third/data/plugins" unzip "$build/rxi-lite-colors.zip" -d "$build" mv "$build/lite-colors-master/colors" "$build/third/data" @@ -221,7 +228,7 @@ if [ -z ${use_branch+set} ]; then use_branch="$(git rev-parse --abbrev-ref HEAD)" fi -build_dir=".build-$arch" +build_dir=".rbuild-$arch" if [ -z ${pgo+set} ]; then lite_build "$build_dir" diff --git a/data/core/compat.lua b/data/core/compat.lua index 3fd66e30..176de905 100644 --- a/data/core/compat.lua +++ b/data/core/compat.lua @@ -1,6 +1,10 @@ -function table.pack(...) - return {n=select('#',...), ...} +local has_jit_module = pcall(require, "jit") +if has_jit_module then + -- when using luajit the function table.pack/unpack are not available + function table.pack(...) + return {n=select('#',...), ...} + end + + table.unpack = unpack end -table.unpack = unpack - diff --git a/meson.build b/meson.build index 9fb0cc51..f4fc35d6 100644 --- a/meson.build +++ b/meson.build @@ -4,8 +4,10 @@ cc = meson.get_compiler('c') libm = cc.find_library('m', required : false) libdl = cc.find_library('dl', required : false) +lite_cargs = [] if get_option('luajit') lua_dep = dependency('luajit', required : false) + lite_cargs += '-DLITE_USE_LUAJIT' if not lua_dep.found() lua_subproject = subproject('luajit', default_options: ['portable=true', 'default_library=static', 'app=false']) lua_dep = lua_subproject.get_variable('lua_dep') @@ -22,7 +24,6 @@ endif sdl_dep = dependency('sdl2', method: 'config-tool') -lite_cargs = [] if get_option('portable') lite_datadir = 'data' else diff --git a/src/api/compat.c b/src/api/compat.c index e08b5a26..7a37845d 100644 --- a/src/api/compat.c +++ b/src/api/compat.c @@ -1,3 +1,5 @@ +#ifdef LITE_USE_LUAJIT + #include #include "compat.h" @@ -61,4 +63,4 @@ void luaL_setmetatable (lua_State *L, const char *tname) { luaL_getmetatable(L, tname); lua_setmetatable(L, -2); } - +#endif diff --git a/src/api/compat.h b/src/api/compat.h index 93220cd5..bfb3ac67 100644 --- a/src/api/compat.h +++ b/src/api/compat.h @@ -4,6 +4,8 @@ #include #include +#ifdef LITE_USE_LUAJIT + #define luaL_newlibtable(L, l) \ (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1)) #define luaL_newlib(L, l) \ @@ -13,5 +15,6 @@ extern void luaL_requiref (lua_State *L, const char *modname, lua_CFunction open extern void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); extern void luaL_setmetatable (lua_State *L, const char *tname); extern int luaL_getsubtable (lua_State *L, int i, const char *name); +#endif #endif