Browse Source

refactor build system to allow pulling libraries from packages, assuming directories are set up correctly

master
XeonSquared 9 months ago
parent
commit
ef2c01b1d4
6 changed files with 48 additions and 15 deletions
  1. +0
    -3
      build.lua
  2. +2
    -1
      build.sh
  3. +2
    -0
      kcfg/base.cfg
  4. +3
    -0
      kcfg/full.cfg
  5. +0
    -11
      module/init.lua
  6. +41
    -0
      preproc.lua

+ 0
- 3
build.lua View File

@@ -1,7 +1,4 @@
local preproc = require "preproc"
--local tA = {...}
function preproc.directives.includelib(file,name)
return string.format("package.loaded.%s = (function()\n%s\nend)()", name, preproc.preproc(file))
end

preproc(...)

+ 2
- 1
build.sh View File

@@ -1,8 +1,9 @@
#!/bin/bash
LUA=${LUA:-lua}
KVAR=${1:-lua}
rm -r target/*
mkdir -p target/doc &>/dev/null
$LUA build.lua module/init.lua target/init.lua
$LUA build.lua kcfg/$KVAR.cfg target/init.lua
echo _OSVERSION=\"PsychOS 2.0a3-$(git rev-parse --short HEAD)\" > target/version.lua
cat target/version.lua target/init.lua > target/tinit.lua
mv target/tinit.lua target/init.lua


+ 2
- 0
kcfg/base.cfg View File

@@ -0,0 +1,2 @@
--#include "module/base.lua"
--#include "module/init.lua"

+ 3
- 0
kcfg/full.cfg View File

@@ -0,0 +1,3 @@
--#include "module/base.lua"
--#include "module/rtfsboot.lua"
--#include "module/init.lua"

+ 0
- 11
module/init.lua View File

@@ -1,14 +1,3 @@
--#include "module/syslog.lua"
--#include "module/sched.lua"
--#include "module/buffer.lua"
--#include "module/osutil.lua"
--#include "module/fs.lua"
--#include "module/io.lua"
--#include "module/devfs.lua"
--#include "module/devfs/syslog.lua"
--#include "module/component-get.lua"
--#include "module/loadfile.lua"

_OSVERSION=_OSVERSION or "PsychOS 2"

os.spawn(function()


+ 41
- 0
preproc.lua View File

@@ -59,6 +59,47 @@ end

preproc.directives.include = preproc.preproc

function preproc.directives.includelib(file, name) -- string string -- string -- Returns a preprocessed inlined library
return string.format("package.loaded.%s = (function()\n%s\nend)()", name, preproc.preproc(file))
end

function preproc.directives.includepkgfile(package, file)
if (_OSVERSION or ""):sub(1,7) == "PsychOS" then
return preproc.preproc(string.format("/pkg/%s", file))
else
for path in (os.getenv("PSYCHOSPACKAGES") or "../PsychOSPackages"):gmatch("[^:]+") do
local f = io.open(string.format("%s/%s/%s", path, package, file), "r")
if f then
f:close()
return preproc.preproc(string.format("%s/%s/%s", path, package, file))
end
end
end
error(string.format("unable to locate file %s from package %s", file, package))
end

function preproc.directives.includepkglib(package, file, name) -- string string -- string -- Returns a preprocessed inlined library
return string.format("package.loaded.%s = (function()\n%s\nend)()", name, preproc.directives.includepkgfile(package, file))
end

--[[
function preproc.directives.includepkglib(package, file, name)
if (_OSVERSION or ""):sub(1,7) == "PsychOS" then
return preproc.directives.includelib(string.format("/pkg/%s", file), name)
else
for path in (os.getenv("PSYCHOSPACKAGES") or "../PsychOSPackages"):gmatch("[^:]+") do
print(string.format("%s/%s/%s", path, package, file))
local f = io.open(string.format("%s/%s/%s", path, package, file), "r")
if f then
f:close()
return preproc.directives.includelib(string.format("%s/%s/%s", path, package, file), name)
end
end
end
error(string.format("unable to locate library %s from package %s", name, package))
end
]]

return setmetatable(preproc,{__call=function(_,...)
local tA = {...}
local out = table.remove(tA,#tA)


Loading…
Cancel
Save