diff --git a/Features/detail/use-version-write-prjver-run.lua b/Features/detail/use-version-write-prjver-run.lua index 07cbaa7..56cd659 100644 --- a/Features/detail/use-version-write-prjver-run.lua +++ b/Features/detail/use-version-write-prjver-run.lua @@ -1,4 +1,20 @@ -local function doAction() +local function GetSnapshotName(full) + local strYear = os.date("%y") + local strMon = os.date("%m") + local iWeekOffset = tonumber(os.date("%w")) - 1 + local iDayOffset = tonumber(os.date("%d")) + local iWeekIdxOffset = math.floor(iDayOffset / 7) + local bWeekTest = iWeekOffset > 2 + local cWeekBase = "A" + if (bWeekTest) then cWeekBase = "a" else cWeekBase = "A" end + if (iWeekIdxOffset > 4) then iWeekIdxOffset = 4 end + local cWeekChar = string.char(string.byte(cWeekBase) + iWeekIdxOffset) + + if (not full) then strYear = strYear:sub(2, 2) end + return strYear .. strMon .. cWeekChar +end + +local function DoAction() local projectName = auBuild.projectName local version = auBuild.projectRoot .. "/Version.json" @@ -15,12 +31,22 @@ local function doAction() 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; + local patchVer = 0 + + if (manifest.patch) then + patchVer = manifest.patch + + if (manifest.incrementPatchOnBuild) then + manifest.patch = patchVer + 1; + end end - + local includeGit = manifest.includeGit + local includeARD = manifest.includeARD + local includeARDExtended = manifest.includeARDExtended + local includeARDFull = manifest.includeARDFull + local relString = "" local commitString = "" if (includeGit) then @@ -33,11 +59,19 @@ local function doAction() commitString = result end end + + if (includeARD) then + relString = GetSnapshotName(includeARDFull) + + if (includeARDExtended) then + relString = relString .. patchVer + end + end io.writefile(version, json.encode_pretty(manifest)) if (manifest.patch) then - manifest.patch = manifest.patch - 1; + manifest.patch = patchVer end local hheader = manifest.hheader or "" @@ -62,8 +96,8 @@ local function doAction() local vis = nil - if (manifest.visability) then - vis = manifest.visability .. " " + if (manifest.visibility) then + vis = manifest.visibility .. " " else vis = "" end @@ -98,6 +132,15 @@ extern "C" cHeaderGitExt = string.format(cHeaderGitExt, vis, projectName) end + if (includeARD) then + local hARDFooter = [[ + + +%sconst char *Get%sAuroraReleaseDate();]] + + cHeaderGitExt = cHeaderGitExt .. string.format(hARDFooter, vis, projectName) + end + local formattedChTemplate = string.format(chTemplate, hheader, vis, projectName, @@ -199,7 +242,6 @@ extern "C" local strMajor = manifest.major or "0" local gitFooter = "" - if (includeGit) then gitFooter = [[ @@ -211,6 +253,24 @@ extern "C" gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"") end + if (manifest.includeARD) then + local atfooter = [[ + +%sconst char *Get%sAuroraReleaseDate() +{ + return %s; +}]] + + if (includeGit) then + atfooter = [[ + +]] .. atfooter + end + + atfooter = string.format(atfooter, vis, projectName, "\"" .. relString .. "\"") + + gitFooter = gitFooter .. atfooter + end local formattedCTemplate = string.format(cTemplate, cheader, @@ -225,4 +285,4 @@ extern "C" io.writefile(versionC, formattedCTemplate) end -return doAction \ No newline at end of file +return DoAction \ No newline at end of file