Improve lua build process + folder structure
This commit is contained in:
parent
cf0be21596
commit
52b4c9000f
29
lua/justfile
29
lua/justfile
@ -1,30 +1,31 @@
|
|||||||
default:
|
default:
|
||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
lua_files := `find . -type f -name "*.lua" ! -path './out/*' ! -name tlconfig.lua ! -name minify.lua -printf "%p "`
|
build: && manifest
|
||||||
teal_files := `find . -type f -name "*.tl" ! -name '*.d.tl' -printf "%p "`
|
tl build
|
||||||
|
@mkdir -p out/vendor
|
||||||
build:
|
find src/vendor -name "*.lua" -exec cp -t out/vendor {} +
|
||||||
mkdir -p out
|
|
||||||
for file in {{lua_files}}; do \
|
|
||||||
lua minify.lua $file; \
|
|
||||||
done
|
|
||||||
for file in {{teal_files}}; do \
|
|
||||||
tl gen $file; \
|
|
||||||
lua minify.lua ${file%.tl}.lua; \
|
|
||||||
rm ${file%.tl}.lua; \
|
|
||||||
done
|
|
||||||
|
|
||||||
alias b := build
|
alias b := build
|
||||||
|
|
||||||
|
manifest_file := "out/manifest.txt"
|
||||||
|
manifest:
|
||||||
|
rm -f {{ manifest_file }}
|
||||||
|
find out -name "*.lua" -exec realpath --relative-to=out {} >> {{ manifest_file }} \;
|
||||||
|
|
||||||
|
min-build: build
|
||||||
|
find out -name "*.lua" -exec lua minify.lua {} \;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -r out
|
rm -r out
|
||||||
|
|
||||||
alias c := clean
|
alias c := clean
|
||||||
|
|
||||||
|
watch_recipe := env_var_or_default("WATCH_RECIPE", "build")
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
while sleep 0.1; do \
|
while sleep 0.1; do \
|
||||||
find . -type f ! -path './out/*' | entr -d just build; \
|
find . -type f ! -path './out/*' | entr -d just {{ watch_recipe }}; \
|
||||||
[ $? -eq 0 ] && exit 0; \
|
[ $? -eq 0 ] && exit 0; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ parser.minify(ast, true)
|
|||||||
|
|
||||||
local output = parser.toLua(ast)
|
local output = parser.toLua(ast)
|
||||||
|
|
||||||
local f = io.open("out/"..filename, "w")
|
local f = io.open(filename, "w")
|
||||||
f:write(output)
|
f:write(output)
|
||||||
f:close()
|
f:close()
|
@ -1,7 +1,7 @@
|
|||||||
local json = require("json")
|
local json = require("vendor/json")
|
||||||
local Framebuffer = require("framebuffer")
|
local Framebuffer = require("lib/framebuffer")
|
||||||
local Ringbuffer = require("ringbuffer")
|
local Ringbuffer = require("lib/ringbuffer")
|
||||||
local Socket = require("socket")
|
local Socket = require("lib/socket")
|
||||||
local auth = require("auth")
|
local auth = require("auth")
|
||||||
local ENDPOINT <const> = auth.server:gsub("http", "ws", 1) .. "/ipmi/computer/" .. auth.id .. "/ws"
|
local ENDPOINT <const> = auth.server:gsub("http", "ws", 1) .. "/ipmi/computer/" .. auth.id .. "/ws"
|
||||||
local HEADERS <const> = { ["Authorization"] = "Bearer " .. auth.token }
|
local HEADERS <const> = { ["Authorization"] = "Bearer " .. auth.token }
|
0
lua/json.lua → lua/src/vendor/json.lua
vendored
0
lua/json.lua → lua/src/vendor/json.lua
vendored
@ -1,4 +1,7 @@
|
|||||||
return {
|
return {
|
||||||
|
source_dir = "src",
|
||||||
|
include_dir = {"src"},
|
||||||
|
build_dir = "out",
|
||||||
global_env_def = "cc",
|
global_env_def = "cc",
|
||||||
gen_target = "5.1",
|
gen_target = "5.1",
|
||||||
}
|
}
|
@ -23,11 +23,22 @@ app.mount("/tiles/", map_tiles)
|
|||||||
app.mount("/ipmi/", monitoring)
|
app.mount("/ipmi/", monitoring)
|
||||||
app.mount("/api/", api)
|
app.mount("/api/", api)
|
||||||
|
|
||||||
installer = j2env.get_template("install.lua").render(deploy_path=settings.deploy_path)
|
|
||||||
|
def render_lua_installer():
|
||||||
|
with open(f"{settings.lua_out_path}/manifest.txt", "r") as f:
|
||||||
|
file_list = [name.strip() for name in f.readlines()]
|
||||||
|
return j2env.get_template("install.lua").render(
|
||||||
|
deploy_path=settings.deploy_path, file_list=file_list
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
installer = render_lua_installer()
|
||||||
|
|
||||||
|
|
||||||
@app.get("/install")
|
@app.get("/install")
|
||||||
async def get_installer():
|
async def get_installer():
|
||||||
|
if settings.dev_mode:
|
||||||
|
installer = render_lua_installer()
|
||||||
return PlainTextResponse(installer)
|
return PlainTextResponse(installer)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local args = { ... }
|
local args = { ... }
|
||||||
|
|
||||||
local token = args[1]
|
local token = args[1]
|
||||||
|
|
||||||
local existing = fs.exists("auth.lua")
|
local existing = fs.exists("auth.lua")
|
||||||
if not token and not existing then
|
if not token and not existing then
|
||||||
error("A token is required.")
|
error("A token is required.")
|
||||||
@ -16,8 +16,8 @@ elseif token then
|
|||||||
error("Token failed!")
|
error("Token failed!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local files = { "main.lua", "json.lua", "framebuffer.lua", "ringbuffer.lua", "socket.lua" }
|
local files = { {% for filename in file_list %} "{{ filename }}", {% endfor %} }
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
fs.delete(file)
|
fs.delete(file)
|
||||||
shell.run(("wget %s/lua/%s"):format(path, file))
|
shell.run(("wget %s/lua/%s %s"):format(path, file, file))
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user