wrote lmk, an more general lua build system

This commit is contained in:
Izaya 2017-10-08 08:22:35 +11:00
parent 83e26739a5
commit 275c50c10d
8 changed files with 97 additions and 4 deletions

View File

@ -1,3 +1,6 @@
lexec genheader.lua
ofile out/everything.lua
header.lua
modules/base/loadlin.lua
modules/debug/log.lua
modules/base/header.lua

View File

@ -1,3 +1,6 @@
lexec genheader.lua
ofile out/headless.lua
header.lua
modules/base/loadlin.lua
modules/debug/log.lua
modules/base/header.lua

View File

@ -1,3 +1,6 @@
lexec genheader.lua
ofile out/minimal.lua
header.lua
modules/base/loadlin.lua
modules/debug/log.lua
modules/base/header.lua

73
exec/lmk.lua Normal file
View File

@ -0,0 +1,73 @@
local tA = {...}
local modlistf = tA[1]
local nk = ""
local oprint = print
print(modlistf)
function print(...)
if tA[2] then
oprint(...)
end
end
f = io.open(modlistf,"rb")
if not f then error("no input file") end
local ofile = nil
local c=f:read("*a")
f:close()
local n=1
local function wcfile()
if ofile then
f=io.open(ofile,"wb")
if f then
oprint("writing file "..ofile)
f:write(nk)
f:close()
else
oprint("warning: unable to open file "..ofile.." to write")
end
end
end
local function apfile(fp)
local f=io.open(fp,"rb")
if f then
nk=nk..f:read("*a")
f:close()
end
end
for line in c:gmatch("[^\r\n]+") do
print(line)
local tw = {}
for w in line:gmatch("%S+") do
tw[#tw+1] = w
end
n=n+1
if tw[1] == "ofile" then
wcfile()
ofile = tw[2]
nk=""
elseif tw[1] == "exec" then
os.execute(tw[2])
elseif tw[1] == "lexec" then
local f=io.open(tw[2],"rb")
if f then
local fc = f:read("*a")
print(fc)
print(pcall(load(fc)))
end
f:close()
elseif tw[1] == "fwrap" then
nk=nk.."function "..tw[2].."(...)\n"
apfile(tw[3])
nk=nk.."\nend\n"
elseif tw[1] == "libwrap" then
nk=nk.."function "..tw[2].."(...)\n"
apfile(tw[3])
nk=nk.."\nend\n_G."..tw[2].." = "..tw[2].."()\n"
elseif tw[1] == "alias" then
nk=nk..tw[2].."="..tw[3].."\n"
elseif tw[1] == "include" then
apfile(tw[2])
elseif #tw == 1 then
apfile(line)
end
end
wcfile()

12
genheader.lua Executable file
View File

@ -0,0 +1,12 @@
local f = io.open("header.lua","wb")
local kname = nil
if not _OSNAME then
local w,gn = pcall(io.popen,"git rev-parse HEAD")
if w then
kname = gn:read():sub(1,7)
gn:close()
end
end
f:write("_OSVERSION=\"PsychOS "..(kname or os.date("%Y/%m/%d %H:%M %z")).."\"\n")
f:write("_BD=\""..os.date("%Y/%m/%d %H:%M %z").."\"\n")
f:close()

View File

@ -1,3 +0,0 @@
#!/usr/bin/env lua
require "modules/applications/genkernel"
print(genkernel(...))

View File

@ -2,6 +2,6 @@
mkdir -p out/
for f in `dir -d configs/*`; do
kn=$(echo $f | cut -f 1 -d '.' | cut -f 2 -d "/")
./genkernel.lua $f "$(git rev-parse --short HEAD)" > out/$kn.lua
lua exec/lmk.lua $f
lua strip.lua out/$kn.lua out/s$kn.lua
done

2
header.lua Normal file
View File

@ -0,0 +1,2 @@
_OSVERSION="PsychOS 83e2673"
_BD="2017/10/08 08:18 +1100"