From b62beff89163ec1b4b22ab3d25daf24370b1eafa Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 1 Aug 2023 18:17:49 +1000 Subject: [PATCH] update preproc so it can still cope with building PsychOS (hopefully) --- preproc/lib/preproc.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/preproc/lib/preproc.lua b/preproc/lib/preproc.lua index 1cdac5a..82d77ce 100644 --- a/preproc/lib/preproc.lua +++ b/preproc/lib/preproc.lua @@ -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)