do not use 'portable' as a compile time option

Introduce the file core/start.lua to initialize applications variables
This commit is contained in:
Francesco Abbate 2021-02-24 16:29:39 +01:00
parent ea8a8770ea
commit 351a772466
5 changed files with 22 additions and 27 deletions

View File

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
if [[ $1 == -portable ]]; then
cflags="-DLITE_XL_DATA_USE_EXEDIR"
fi
cflags+="-Wall -O3 -g -std=gnu11 -fno-strict-aliasing -Isrc -Ilib/font_renderer" cflags+="-Wall -O3 -g -std=gnu11 -fno-strict-aliasing -Isrc -Ilib/font_renderer"
cflags+=" $(pkg-config --cflags lua5.2) $(sdl2-config --cflags)" cflags+=" $(pkg-config --cflags lua5.2) $(sdl2-config --cflags)"
lflags="-static-libgcc -static-libstdc++" lflags="-static-libgcc -static-libstdc++"

View File

@ -1,5 +1,3 @@
global {VERSION = "1.16.0"}
local config = {} local config = {}
config.project_scan_rate = 5 config.project_scan_rate = 5

17
data/core/start.lua Normal file
View File

@ -0,0 +1,17 @@
-- this file is used by lite-xl to setup the Lua environment
-- when starting
VERSION = "1.16.0"
SCALE = tonumber(os.getenv("LITE_SCALE")) or SCALE
PATHSEP = package.config:sub(1, 1)
EXEDIR = EXEFILE:match("^(.+)[/\\][^/\\]+$")
local prefix = EXEDIR:match("^(.+)[/\\]bin$")
DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')
USERDIR = HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user')
package.path = package.path .. ';' .. USERDIR .. '/?.lua'
package.path = package.path .. ';' .. USERDIR .. '/?/init.lua'
package.path = DATADIR .. '/?.lua;' .. package.path
package.path = DATADIR .. '/?/init.lua;' .. package.path

View File

@ -1,4 +1,4 @@
project('lite', 'c', 'cpp', version: '1.0', default_options : ['c_std=gnu11', 'cpp_std=c++03']) project('lite', 'c', 'cpp', default_options : ['c_std=gnu11', 'cpp_std=c++03'])
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
libm = cc.find_library('m', required : false) libm = cc.find_library('m', required : false)
@ -16,7 +16,6 @@ sdl_dep = dependency('sdl2', method: 'config-tool')
lite_cargs = [] lite_cargs = []
if get_option('portable') if get_option('portable')
lite_cargs += ['-DLITE_XL_DATA_USE_EXEDIR']
lite_datadir = 'data' lite_datadir = 'data'
else else
lite_datadir = 'share/lite-xl' lite_datadir = 'share/lite-xl'

View File

@ -114,31 +114,16 @@ init_lua:
lua_pushstring(L, exename); lua_pushstring(L, exename);
lua_setglobal(L, "EXEFILE"); lua_setglobal(L, "EXEFILE");
const char *init_lite_code = \ const char *init_lite_code = \
"local core\n" "local core\n"
"xpcall(function()\n" "xpcall(function()\n"
" SCALE = tonumber(os.getenv(\"LITE_SCALE\")) or SCALE\n"
" PATHSEP = package.config:sub(1, 1)\n"
" EXEDIR = EXEFILE:match(\"^(.+)[/\\\\].*$\")\n"
#ifdef LITE_XL_DATA_USE_EXEDIR
" DATADIR = EXEDIR .. '/data'\n"
#else
" do\n"
" local prefix = EXEDIR:match(\"^(.+)[/\\\\]bin$\")\n"
" DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')\n"
" end\n"
#endif
#ifdef _WIN32 #ifdef _WIN32
" HOME = os.getenv('USERPROFILE')" " HOME = os.getenv('USERPROFILE')\n"
#else #else
" HOME = os.getenv('HOME')" " HOME = os.getenv('HOME')\n"
#endif #endif
" USERDIR = HOME and (HOME .. '/.config/lite-xl') or (EXEDIR .. '/user')\n" " local prefix = EXEFILE:match(\"^(.+)[/\\\\]bin[/\\\\][^/\\\\]+$\")\n"
" package.path = package.path .. ';' .. USERDIR .. '/?.lua'\n" " dofile((prefix and prefix .. '/share/lite-xl' or 'data') .. '/core/start.lua')\n"
" package.path = package.path .. ';' .. USERDIR .. '/?/init.lua'\n"
" package.path = DATADIR .. '/?.lua;' .. package.path\n"
" package.path = DATADIR .. '/?/init.lua;' .. package.path\n"
" core = require('core')\n" " core = require('core')\n"
" core.init()\n" " core.init()\n"
" core.run()\n" " core.run()\n"