Add flags to run both luajit and lua

This commit is contained in:
Francesco Abbate 2021-03-22 08:51:26 +01:00
parent 198642b0cf
commit 6f9926b582
5 changed files with 26 additions and 9 deletions

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
#ifdef LITE_USE_LUAJIT
#include <lauxlib.h>
#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

View File

@ -4,6 +4,8 @@
#include <lua.h>
#include <lauxlib.h>
#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