Compare commits
5 Commits
amiga2.1
...
using-luaj
Author | SHA1 | Date |
---|---|---|
Francesco Abbate | c110812963 | |
Francesco Abbate | 6f9926b582 | |
Francesco Abbate | 198642b0cf | |
Francesco Abbate | 3853bf73d7 | |
Francesco Abbate | 7ad4ec36ce |
|
@ -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"
|
||||
|
@ -230,5 +237,6 @@ else
|
|||
fi
|
||||
lite_copy_third_party_modules "$build_dir"
|
||||
lite_build_package "$build_dir" "$arch"
|
||||
lite_build_package -portable "$build_dir" "$arch"
|
||||
|
||||
if [[ ! ( "$OSTYPE" == "linux"* || "$OSTYPE" == "freebsd"* ) ]]; then
|
||||
lite_build_package -portable "$build_dir" "$arch"
|
||||
fi
|
||||
|
|
|
@ -8,7 +8,7 @@ end
|
|||
|
||||
|
||||
function common.utf8_chars(text)
|
||||
return text:gmatch("[\0-\x7f\xc2-\xf4][\x80-\xbf]*")
|
||||
return text:gmatch("[\x01-\x7f\xc2-\xf4][\x80-\xbf]*")
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
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
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
require "core.strict"
|
||||
require "core.compat"
|
||||
local common = require "core.common"
|
||||
local config = require "core.config"
|
||||
local style = require "core.style"
|
||||
|
|
23
meson.build
23
meson.build
|
@ -3,18 +3,27 @@ project('lite', 'c', 'cpp', default_options : ['c_std=gnu11', 'cpp_std=c++03'])
|
|||
cc = meson.get_compiler('c')
|
||||
libm = cc.find_library('m', required : false)
|
||||
libdl = cc.find_library('dl', required : false)
|
||||
lua_dep = dependency('lua5.2', required : false)
|
||||
|
||||
if not lua_dep.found()
|
||||
lua_subproject = subproject('lua', default_options: [
|
||||
'shared=false', 'use_readline=false', 'app=false'
|
||||
])
|
||||
lua_dep = lua_subproject.get_variable('lua_dep')
|
||||
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')
|
||||
endif
|
||||
else
|
||||
lua_dep = dependency('lua5.2', required : false)
|
||||
if not lua_dep.found()
|
||||
lua_subproject = subproject('lua', default_options: [
|
||||
'shared=false', 'use_readline=false', 'app=false'
|
||||
])
|
||||
lua_dep = lua_subproject.get_variable('lua_dep')
|
||||
endif
|
||||
endif
|
||||
|
||||
sdl_dep = dependency('sdl2', method: 'config-tool')
|
||||
|
||||
lite_cargs = []
|
||||
if get_option('portable')
|
||||
lite_datadir = 'data'
|
||||
else
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
option('portable', type : 'boolean', value : false, description: 'Portable install')
|
||||
option('luajit', type : 'boolean', value : true, description: 'Use luajit')
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#define API_TYPE_FONT "Font"
|
||||
|
||||
void api_load_libs(lua_State *L);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
#ifdef LITE_USE_LUAJIT
|
||||
|
||||
#include <lauxlib.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
static int lua_absindex (lua_State *L, int i) {
|
||||
if (i < 0 && i > LUA_REGISTRYINDEX)
|
||||
i += lua_gettop(L) + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
int luaL_getsubtable (lua_State *L, int i, const char *name) {
|
||||
int abs_i = lua_absindex(L, i);
|
||||
luaL_checkstack(L, 3, "not enough stack slots");
|
||||
lua_pushstring(L, name);
|
||||
lua_gettable(L, abs_i);
|
||||
if (lua_istable(L, -1))
|
||||
return 1;
|
||||
lua_pop(L, 1);
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, name);
|
||||
lua_pushvalue(L, -2);
|
||||
lua_settable(L, abs_i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb) {
|
||||
luaL_checkstack(L, 3, "not enough stack slots available");
|
||||
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
|
||||
lua_getfield(L, -1, modname);
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
lua_pushcfunction(L, openf);
|
||||
lua_pushstring(L, modname);
|
||||
lua_call(L, 1, 1);
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setfield(L, -3, modname);
|
||||
}
|
||||
if (glb) {
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setglobal(L, modname);
|
||||
}
|
||||
lua_replace(L, -2);
|
||||
}
|
||||
|
||||
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
|
||||
luaL_checkstack(L, nup+1, "too many upvalues");
|
||||
for (; l->name != NULL; l++) { /* fill the table with given functions */
|
||||
int i;
|
||||
lua_pushstring(L, l->name);
|
||||
for (i = 0; i < nup; i++) /* copy upvalues to the top */
|
||||
lua_pushvalue(L, -(nup + 1));
|
||||
lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
|
||||
lua_settable(L, -(nup + 3)); /* table must be below the upvalues, the name and the closure */
|
||||
}
|
||||
lua_pop(L, nup); /* remove upvalues */
|
||||
}
|
||||
|
||||
|
||||
void luaL_setmetatable (lua_State *L, const char *tname) {
|
||||
luaL_checkstack(L, 1, "not enough stack slots");
|
||||
luaL_getmetatable(L, tname);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef COMPAT_H
|
||||
#define COMPAT_H
|
||||
|
||||
#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) \
|
||||
(luaL_newlibtable(L, l), luaL_register(L, NULL, l))
|
||||
|
||||
extern void luaL_requiref (lua_State *L, const char *modname, lua_CFunction openf, int glb);
|
||||
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
|
|
@ -1,4 +1,5 @@
|
|||
lite_sources = [
|
||||
'api/compat.c',
|
||||
'api/api.c',
|
||||
'api/renderer.c',
|
||||
'api/renderer_font.c',
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[wrap-git]
|
||||
directory = luajit
|
||||
url = https://github.com/franko/luajit
|
||||
revision = v2.0.5-test-1
|
||||
|
Loading…
Reference in New Issue