Attempt to read build information from the users build scripts directory

Ensure all build scripts are executed relative to the projects root directory
This commit is contained in:
Reece Wilson 2021-05-27 11:02:12 +01:00
parent f1c12b4937
commit 3d5cc16ca8
2 changed files with 28 additions and 11 deletions

View File

@ -1,7 +1,7 @@
local auProject = require("project") local auProject = require("project")
function JsonProcessor(info) function JsonProcessor(info)
local result, err = json.decode(io.readfile(info.path .. "/Aurora.json")) local result, err = json.decode(io.readfile(info.jpath))
if (not result) then if (not result) then
print("parse error", info.path, err) print("parse error", info.path, err)
@ -211,9 +211,6 @@ function JsonProcessor(info)
_G["info"] = info _G["info"] = info
local cwd = os.getcwd()
os.chdir(info.path)
if (_if) then if (_if) then
print("DEBUG: IF?? ", _if) print("DEBUG: IF?? ", _if)
@ -233,7 +230,6 @@ function JsonProcessor(info)
end end
end end
os.chdir(cwd)
_G["info"] = nil _G["info"] = nil
end end

View File

@ -84,9 +84,22 @@ function addVisit(ina)
processor = nil processor = nil
} }
if (os.isfile(path .. "/Aurora.lua")) then local cwd = getroot()
project.processor = require(path .. "/Aurora.lua")(info)
elseif (os.isfile(path .. "/Aurora.json")) then local remoteLua = path .. "/Aurora.lua"
local remoteJson = path .. "/Aurora.json"
local localJson = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.json"
local localLua = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.lua"
if (os.isfile(localLua)) then
project.processor = require(localLua)(info)
elseif (os.isfile(localJson)) then
info.jpath = localJson
project.processor = jsonProcessor(info)
elseif (os.isfile(remoteLua)) then
project.processor = require(remoteLua)(info)
elseif (os.isfile(remoteJson)) then
info.jpath = remoteJson
project.processor = jsonProcessor(info) project.processor = jsonProcessor(info)
else else
print("Couldnt find Aurora build script for: ", path) print("Couldnt find Aurora build script for: ", path)
@ -160,16 +173,24 @@ function processSubproject(name)
return return
end end
local ns = a.info.namespace local info = a.info
local ns = info.namespace
if (not namespacesemitted[ns]) then if (not namespacesemitted[ns]) then
namespacesemitted[ns] = ""; namespacesemitted[ns] = "";
dbgGroup(ns) dbgGroup(ns)
end end
local s = _G["current_project"] local cwd = os.getcwd()
local old = _G["current_project"]
_G["current_project"] = name _G["current_project"] = name
os.chdir(info.path)
a.processor:process(a.processor) a.processor:process(a.processor)
_G["current_project"] = s
os.chdir(cwd)
_G["current_project"] = old
projectsemitted[name] = name projectsemitted[name] = name
end end