diff --git a/Features/detail/use-version-write-prjver-run.lua b/Features/detail/use-version-write-prjver-run.lua index 0299980..39c08a1 100644 --- a/Features/detail/use-version-write-prjver-run.lua +++ b/Features/detail/use-version-write-prjver-run.lua @@ -1,12 +1,19 @@ -local version = auBuild.projectRoot .. "/Version.json" -local versionH = auBuild.projectRoot .. "/Source/AuVersion.h" -local versionHPP = auBuild.projectRoot .. "/Source/AuVersion.hpp" -local versionC = auBuild.projectRoot .. "/Source/AuVersion.c" - local projectName = auBuild.projectName +local version = auBuild.projectRoot .. "/Version.json" 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 @@ -15,6 +22,8 @@ local includeGit = manifest.includeGit local commitString = "" +os.chdir(auBuild.root) + if (includeGit) then local cmd = nil if (auBuild.shortGitCommit) then @@ -46,7 +55,9 @@ local chTemplate = [[ %suint16_ct Get%sMinorVersion(); -%suint16_ct Get%sMajorVersion();%s +%suint16_ct Get%sMajorVersion(); + +%suint32_ct Get%sGitVersionDetail();%s ]] @@ -58,12 +69,22 @@ else vis = "" end +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" { - #include "AuVersion.h" + #include "%sVersion.h" } ]] @@ -84,6 +105,7 @@ local formattedChTemplate = string.format(chTemplate, vis, projectName, vis, projectName, vis, projectName, + vis, projectName, cHeaderGitExt ) @@ -92,10 +114,9 @@ if (not os.isfile(versionH)) then end if (not os.isfile(versionHPP)) then - io.writefile(versionHPP, cppTemplate) + io.writefile(versionHPP, string.format(cppTemplate, projectName)) end - local cheader = manifest.cheader or "" local cTemplate = [[ @@ -141,6 +162,11 @@ local cTemplate = [[ return g_result = result; } + +%suint32_ct Get%sGitVersionDetail() +{ + return %su | (%s << 1u); +} %s]] local hashTemplateA = [[ @@ -177,12 +203,11 @@ local gitFooter = "" if (includeGit) then gitFooter = [[ - + %sconst char *Get%sCommitString() { return %s; -} - ]] +}]] gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"") end @@ -194,6 +219,7 @@ local formattedCTemplate = string.format(cTemplate, vis, projectName, strMinor, vis, projectName, strMajor, vis, projectName, hashTemplate, + vis, projectName, manifest.includeGit and "1" or "0", auBuild.shortGitCommit and "1" or "0", gitFooter ) diff --git a/Features/use-version-write-prjver.lua b/Features/use-version-write-prjver.lua index a5383ee..67446e9 100644 --- a/Features/use-version-write-prjver.lua +++ b/Features/use-version-write-prjver.lua @@ -1,7 +1,8 @@ local function feature() - files "Source/AuVersion.h" - files "Source/AuVersion.hpp" - files "Source/AuVersion.c" + local name = auGetCurrentProject() + files("Source/" .. name .. "Version.h") + files("Source/" .. name .. "Version.hpp") + files("Source/" .. name .. "Version.c") auAddBuildAction("pre", "lua", path.join(Aurora.Settings.sAbsScripts, "Features", "detail", "use-version-write-prjver-run.lua"), true) end