diff --git a/Core/Actions/buildActionBootstrap.lua b/Core/Actions/buildActionBootstrap.lua index f68571e..74d63b4 100644 --- a/Core/Actions/buildActionBootstrap.lua +++ b/Core/Actions/buildActionBootstrap.lua @@ -72,12 +72,17 @@ if (projectBins) then end local cwd = _OPTIONS["cwd"] +local passThroughCWD = nil if (cwd) then os.chdir(projRoot) + passThroughCWD = projRoot else os.chdir(Aurora.Settings.sAbsRoot) + passThroughCWD = Aurora.Settings.sAbsRoot end +local root = Aurora.Settings.sAbsRoot + local args = _OPTIONS["additional"] if (args) then local path = _G.path.join(Aurora.Settings.sAbsCompilerWd, args .. ".args") @@ -198,15 +203,22 @@ auBuild = projectTargetName = targetName, projectTargetFileName = fileName, args = args, - root = cwd + root = root, + cwd = passThroughCWD } local luaScript = _OPTIONS["luascript"] local luaAbsScript = _OPTIONS["luaabsscript"] +local fn = nil if (luaScript) then - auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript)) + fn = auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript)) 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 os.exit() \ No newline at end of file diff --git a/Features/detail/use-version-write-prjver-run.lua b/Features/detail/use-version-write-prjver-run.lua index 39c08a1..07cbaa7 100644 --- a/Features/detail/use-version-write-prjver-run.lua +++ b/Features/detail/use-version-write-prjver-run.lua @@ -1,49 +1,48 @@ -local projectName = auBuild.projectName -local version = auBuild.projectRoot .. "/Version.json" +local function doAction() + local projectName = auBuild.projectName + local version = auBuild.projectRoot .. "/Version.json" -local manifest = json.decode(io.readfile(version)) + local manifest = json.decode(io.readfile(version)) -local prjex = "" -if (not manifest.noPrjName) then - prjex = projectName -else - prjex = "Au" -end - -local versionH = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.h" -local versionHPP = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.hpp" -local versionC = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.c" - -if (manifest.patch and manifest.incrementPatchOnBuild) then - manifest.patch = manifest.patch + 1; -end - -local includeGit = manifest.includeGit - -local commitString = "" - -os.chdir(auBuild.root) - -if (includeGit) then - local cmd = nil - if (auBuild.shortGitCommit) then - local result, errorCode = os.outputof("git rev-parse --short HEAD") - commitString = result + local prjex = "" + if (not manifest.noPrjName) then + prjex = projectName else - local result, errorCode = os.outputof("git rev-parse --verify HEAD") - commitString = result + prjex = "Au" end -end -io.writefile(version, json.encode_pretty(manifest)) + local versionH = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.h" + local versionHPP = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.hpp" + local versionC = auBuild.projectRoot .. "/Source/" .. prjex .. "Version.c" -if (manifest.patch) then - manifest.patch = manifest.patch - 1; -end + if (manifest.patch and manifest.incrementPatchOnBuild) then + manifest.patch = manifest.patch + 1; + end -local hheader = manifest.hheader or "" + local includeGit = manifest.includeGit -local chTemplate = [[ + local commitString = "" + + if (includeGit) then + local cmd = nil + if (auBuild.shortGitCommit) then + local result, errorCode = os.outputof("git rev-parse --short HEAD") + commitString = result + else + local result, errorCode = os.outputof("git rev-parse --verify HEAD") + commitString = result + end + end + + io.writefile(version, json.encode_pretty(manifest)) + + if (manifest.patch) then + manifest.patch = manifest.patch - 1; + end + + local hheader = manifest.hheader or "" + + local chTemplate = [[ // Aurora Build Pipeline: Auto-generated Version File #include "AuroraTypes.h" @@ -61,25 +60,25 @@ local chTemplate = [[ ]] -local vis = nil + local vis = nil -if (manifest.visability) then - vis = manifest.visability .. " " -else - vis = "" -end - -if (includeGit) then - hheader = hheader .. "\n" - - if (shortGitCommit) then - hheader = hheader .. "#define VER_" .. string.upper(projectName) .. "_USES_SMALL_HASH 1\n" + if (manifest.visability) then + vis = manifest.visability .. " " + else + vis = "" end - - hheader = hheader .. "#define VER_" .. string.upper(projectName) .. "_HAS_GIT_VERSION 1\n" -end -local cppTemplate = [[ + if (includeGit) then + hheader = hheader .. "\n" + + if (shortGitCommit) then + hheader = hheader .. "#define VER_" .. string.upper(projectName) .. "_USES_SMALL_HASH 1\n" + end + + hheader = hheader .. "#define VER_" .. string.upper(projectName) .. "_HAS_GIT_VERSION 1\n" + end + + local cppTemplate = [[ // Aurora Build Pipeline: Auto-generated Version File extern "C" @@ -88,38 +87,38 @@ extern "C" } ]] -local cHeaderGitExt = "" + local cHeaderGitExt = "" -if (includeGit) then - cHeaderGitExt = [[ + if (includeGit) then + cHeaderGitExt = [[ %sconst char *Get%sCommitString();]] - - cHeaderGitExt = string.format(cHeaderGitExt, vis, projectName) -end + + cHeaderGitExt = string.format(cHeaderGitExt, vis, projectName) + end -local formattedChTemplate = string.format(chTemplate, - hheader, - vis, projectName, - vis, projectName, - vis, projectName, - vis, projectName, - vis, projectName, - cHeaderGitExt -) + local formattedChTemplate = string.format(chTemplate, + hheader, + vis, projectName, + vis, projectName, + vis, projectName, + vis, projectName, + vis, projectName, + cHeaderGitExt + ) -if (not os.isfile(versionH)) then - io.writefile(versionH, formattedChTemplate) -end + if (not os.isfile(versionH)) then + io.writefile(versionH, formattedChTemplate) + end -if (not os.isfile(versionHPP)) then - io.writefile(versionHPP, string.format(cppTemplate, projectName)) -end + if (not os.isfile(versionHPP)) then + io.writefile(versionHPP, string.format(cppTemplate, projectName)) + end -local cheader = manifest.cheader or "" + local cheader = manifest.cheader or "" -local cTemplate = [[ + local cTemplate = [[ // Aurora Build Pipeline: Auto-generated Version File #define FNV1_MAGIC_VAL32 0x811c9dc5u @@ -169,58 +168,61 @@ local cTemplate = [[ } %s]] -local hashTemplateA = [[ - struct dummy - { - uint16_ct a; - uint16_ct b; - uint16_ct c; - } info; + local hashTemplateA = [[ + struct dummy + { + uint16_ct a; + uint16_ct b; + uint16_ct c; + } info; - info.a = Get%sPatchVersion(); - info.b = Get%sMinorVersion(); - info.c = Get%sMajorVersion(); + info.a = Get%sPatchVersion(); + info.b = Get%sMinorVersion(); + info.c = Get%sMajorVersion(); ]] -local hashTemplateB = [[ + local hashTemplateB = [[ const char info[sizeof(%s)] = %s; ]] -local hashTemplate = nil + local hashTemplate = nil -if (not includeGit) then - hashTemplate = string.format(hashTemplateA, projectName, projectName, projectName) -else - hashTemplate = string.format(hashTemplateB, "\"" .. commitString .. "\"", "\"" .. commitString .. "\"") -end + if (not includeGit) then + hashTemplate = string.format(hashTemplateA, projectName, projectName, projectName) + else + hashTemplate = string.format(hashTemplateB, "\"" .. commitString .. "\"", "\"" .. commitString .. "\"") + end -local strVerHash = "" -local strPatch = manifest.patch or "0" -local strMinor = manifest.minor or "0" -local strMajor = manifest.major or "0" -local gitFooter = "" + local strVerHash = "" + local strPatch = manifest.patch or "0" + local strMinor = manifest.minor or "0" + local strMajor = manifest.major or "0" + local gitFooter = "" -if (includeGit) then - gitFooter = [[ + if (includeGit) then + gitFooter = [[ %sconst char *Get%sCommitString() { return %s; }]] - - gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"") + + gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"") + end + + + local formattedCTemplate = string.format(cTemplate, + cheader, + vis, projectName, strPatch, + vis, projectName, strMinor, + vis, projectName, strMajor, + vis, projectName, hashTemplate, + vis, projectName, manifest.includeGit and "1" or "0", auBuild.shortGitCommit and "1" or "0", + gitFooter + ) + + io.writefile(versionC, formattedCTemplate) end - -local formattedCTemplate = string.format(cTemplate, - cheader, - vis, projectName, strPatch, - vis, projectName, strMinor, - vis, projectName, strMajor, - vis, projectName, hashTemplate, - vis, projectName, manifest.includeGit and "1" or "0", auBuild.shortGitCommit and "1" or "0", - gitFooter -) - -io.writefile(versionC, formattedCTemplate) \ No newline at end of file +return doAction \ No newline at end of file