mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2025-02-19 15:12:14 -05:00
Compare commits
No commits in common. "58c9a5492ee9ab851aada91421ffab44e4cfc244" and "7dda36fd1dbc108f5e0e080d200b2034ee2662a8" have entirely different histories.
58c9a5492e
...
7dda36fd1d
@ -1,3 +0,0 @@
|
|||||||
local preproc = require "preproc"
|
|
||||||
--local tA = {...}
|
|
||||||
preproc(...)
|
|
4
build.sh
4
build.sh
@ -2,8 +2,8 @@
|
|||||||
LUA=${LUA:-lua}
|
LUA=${LUA:-lua}
|
||||||
rm -r target/*
|
rm -r target/*
|
||||||
mkdir -p target/doc &>/dev/null
|
mkdir -p target/doc &>/dev/null
|
||||||
$LUA build.lua module/init.lua target/init.lua
|
$LUA luapreproc.lua module/init.lua target/init.lua
|
||||||
echo _OSVERSION=\"PsychOS 2.0a3-$(git rev-parse --short HEAD)\" > target/version.lua
|
echo _OSVERSION=\"PsychOS 2.0a2-$(git rev-parse --short HEAD)\" > target/version.lua
|
||||||
cat target/version.lua target/init.lua > target/tinit.lua
|
cat target/version.lua target/init.lua > target/tinit.lua
|
||||||
mv target/tinit.lua target/init.lua
|
mv target/tinit.lua target/init.lua
|
||||||
cp -r service/ lib/ cfg/ target/
|
cp -r service/ lib/ cfg/ target/
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
local preproc = {}
|
|
||||||
preproc.directives = {}
|
|
||||||
|
|
||||||
function preproc.parsewords(line) -- string -- table -- Returns a table of words from the string *line*, parsing quotes and escapes.
|
|
||||||
local rt = {""}
|
|
||||||
local escaped, quoted = false, false
|
|
||||||
for c in line:gmatch(".") do
|
|
||||||
if escaped then
|
|
||||||
rt[#rt] = rt[#rt]..c
|
|
||||||
elseif c == '"' or c == "'" then
|
|
||||||
quoted = not quoted
|
|
||||||
elseif c == "\\" then
|
|
||||||
escaped = true
|
|
||||||
elseif c:match("%s") and not quoted and rt[#rt]:len() > 0 then
|
|
||||||
rt[#rt+1] = ""
|
|
||||||
else
|
|
||||||
rt[#rt] = rt[#rt]..c
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return rt
|
|
||||||
end
|
|
||||||
|
|
||||||
function preproc.line(line) -- string -- -- Returns either a function - which can be called to get lines until it returns nil - or a string from processing *line* using preprocessor directives.
|
|
||||||
if line:match("^%-%-#") then
|
|
||||||
local directive, args = line:match("^%-%-#(%S+)%s(.+)")
|
|
||||||
print(directive,args)
|
|
||||||
local args = preproc.parsewords(args)
|
|
||||||
if preproc.directives[directive] then
|
|
||||||
return preproc.directives[directive](table.unpack(args))
|
|
||||||
else
|
|
||||||
error("unknown preprocessor directive: "..directive)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return line
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function preproc.preproc(...) -- string -- string -- Returns the output from preprocessing the files listed in *...*.
|
|
||||||
local tA = {...}
|
|
||||||
local output = ""
|
|
||||||
for _,fname in ipairs(tA) do
|
|
||||||
local f,e = io.open(fname)
|
|
||||||
if not f then error("unable to open file "..fname..": "..e) end
|
|
||||||
for line in f:lines() do
|
|
||||||
local r = preproc.line(line)
|
|
||||||
if type(r) == "function" then
|
|
||||||
while true do
|
|
||||||
local rs = r()
|
|
||||||
if not rs then break end
|
|
||||||
output = output .. rs .. "\n"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
output = output .. r .. "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return output
|
|
||||||
end
|
|
||||||
|
|
||||||
preproc.directives.include = preproc.preproc
|
|
||||||
|
|
||||||
return setmetatable(preproc,{__call=function(_,...)
|
|
||||||
local tA = {...}
|
|
||||||
local out = table.remove(tA,#tA)
|
|
||||||
local f,e = io.open(out,"wb")
|
|
||||||
if not f then error("unable to open file "..out..": "..e) end
|
|
||||||
f:write(preproc.preproc(table.unpack(tA)))
|
|
||||||
f:close()
|
|
||||||
end})
|
|
@ -8,8 +8,6 @@
|
|||||||
--#include "module/devfs/syslog.lua"
|
--#include "module/devfs/syslog.lua"
|
||||||
--#include "module/loadfile.lua"
|
--#include "module/loadfile.lua"
|
||||||
|
|
||||||
_OSVERSION=_OSVERSION or "PsychOS 2"
|
|
||||||
|
|
||||||
os.spawn(function()
|
os.spawn(function()
|
||||||
os.setenv("PWD","/boot")
|
os.setenv("PWD","/boot")
|
||||||
io.input("/dev/null")
|
io.input("/dev/null")
|
||||||
|
@ -1 +0,0 @@
|
|||||||
lib/preproc.lua
|
|
Loading…
Reference in New Issue
Block a user