update preproc so it can still cope with building PsychOS (hopefully)

This commit is contained in:
Izaya 2023-08-01 18:17:49 +10:00
parent d8dbaccd2a
commit b62beff891
1 changed files with 41 additions and 0 deletions

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)