From 0a6e0a341853746efb1f7b75f201e32f06923902 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Tue, 11 Oct 2022 18:34:07 +0200 Subject: [PATCH] run(justfile): run recipe run sources with Teal --- justfile | 8 +++++++- set_paths.lua | 10 +++++++++- set_paths.tl | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 set_paths.tl diff --git a/justfile b/justfile index 60ab4e2..d4099e0 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,8 @@ lua_version := "5.4" lua := "lua" + " -l set_paths" +tl := "tl run" + " -l set_paths" + rocks_tree := "lua_modules" rockspec_file := "rockspecs/awesomewm.d.tl-dev-1.rockspec" @@ -36,8 +38,12 @@ clean: rm -rf build run: - {{ lua }} build/awesomewm.d.tl/init.lua + {{ tl }} src/awesomewm.d.tl/init.tl # TODO : how to run a debugger on Teal code? debug: {{ lua }} debug.lua build/awesomewm.d.tl/init.lua +debug-gen: + cyan gen --output set_paths.lua set_paths.tl + sed -i 's/"src\/awesomewm.d.tl"/"build\/awesomewm.d.tl"/g' set_paths.lua + stylua set_paths.lua diff --git a/set_paths.lua b/set_paths.lua index 388addf..4c78256 100644 --- a/set_paths.lua +++ b/set_paths.lua @@ -1,4 +1,12 @@ --- set_paths.lua +local _tl_compat +if (tonumber((_VERSION or ""):match "[%d.]*$") or 0) < 5.3 then + local p, m = pcall(require, "compat53.module") + if p then + _tl_compat = m + end +end +local package = _tl_compat and _tl_compat.package or package +local string = _tl_compat and _tl_compat.string or string local version = _VERSION:match "%d+%.%d+" local function lua_module_paths(module_base_path) diff --git a/set_paths.tl b/set_paths.tl new file mode 100644 index 0000000..5473872 --- /dev/null +++ b/set_paths.tl @@ -0,0 +1,16 @@ +-- set_paths.lua +local version = _VERSION:match "%d+%.%d+" + +local function lua_module_paths(module_base_path: string): string + local paths = (module_base_path .. "/?.lua;") + .. (module_base_path .. "/?/init.lua;") + + return paths +end + +package.path = lua_module_paths("lua_modules/share/lua/" .. version) + .. lua_module_paths "types" + .. lua_module_paths "build/awesomewm.d.tl" + .. package.path + +package.cpath = "lua_modules/lib/lua/" .. version .. "/?.so;" .. package.cpath