[*] improve feature script cwd awareness

This commit is contained in:
Reece Wilson 2023-09-12 15:31:59 +01:00
parent ad4696983a
commit 21e2df1ebb
2 changed files with 132 additions and 118 deletions

View File

@ -72,12 +72,17 @@ if (projectBins) then
end end
local cwd = _OPTIONS["cwd"] local cwd = _OPTIONS["cwd"]
local passThroughCWD = nil
if (cwd) then if (cwd) then
os.chdir(projRoot) os.chdir(projRoot)
passThroughCWD = projRoot
else else
os.chdir(Aurora.Settings.sAbsRoot) os.chdir(Aurora.Settings.sAbsRoot)
passThroughCWD = Aurora.Settings.sAbsRoot
end end
local root = Aurora.Settings.sAbsRoot
local args = _OPTIONS["additional"] local args = _OPTIONS["additional"]
if (args) then if (args) then
local path = _G.path.join(Aurora.Settings.sAbsCompilerWd, args .. ".args") local path = _G.path.join(Aurora.Settings.sAbsCompilerWd, args .. ".args")
@ -198,15 +203,22 @@ auBuild =
projectTargetName = targetName, projectTargetName = targetName,
projectTargetFileName = fileName, projectTargetFileName = fileName,
args = args, args = args,
root = cwd root = root,
cwd = passThroughCWD
} }
local luaScript = _OPTIONS["luascript"] local luaScript = _OPTIONS["luascript"]
local luaAbsScript = _OPTIONS["luaabsscript"] local luaAbsScript = _OPTIONS["luaabsscript"]
local fn = nil
if (luaScript) then if (luaScript) then
auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript)) fn = auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript))
elseif (luaAbsScript) then elseif (luaAbsScript) then
auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript)) fn = auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript))
end
if (type(fn) == "function") then
os.chdir(passThroughCWD)
fn()
end end
os.exit() os.exit()

View File

@ -1,3 +1,4 @@
local function doAction()
local projectName = auBuild.projectName local projectName = auBuild.projectName
local version = auBuild.projectRoot .. "/Version.json" local version = auBuild.projectRoot .. "/Version.json"
@ -22,8 +23,6 @@ local includeGit = manifest.includeGit
local commitString = "" local commitString = ""
os.chdir(auBuild.root)
if (includeGit) then if (includeGit) then
local cmd = nil local cmd = nil
if (auBuild.shortGitCommit) then if (auBuild.shortGitCommit) then
@ -224,3 +223,6 @@ local formattedCTemplate = string.format(cTemplate,
) )
io.writefile(versionC, formattedCTemplate) io.writefile(versionC, formattedCTemplate)
end
return doAction