[*] Improve version feature scripts
This commit is contained in:
parent
00fcdc102e
commit
ad4696983a
@ -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 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
|
if (manifest.patch and manifest.incrementPatchOnBuild) then
|
||||||
manifest.patch = manifest.patch + 1;
|
manifest.patch = manifest.patch + 1;
|
||||||
end
|
end
|
||||||
@ -15,6 +22,8 @@ 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
|
||||||
@ -46,7 +55,9 @@ local chTemplate = [[
|
|||||||
|
|
||||||
%suint16_ct Get%sMinorVersion();
|
%suint16_ct Get%sMinorVersion();
|
||||||
|
|
||||||
%suint16_ct Get%sMajorVersion();%s
|
%suint16_ct Get%sMajorVersion();
|
||||||
|
|
||||||
|
%suint32_ct Get%sGitVersionDetail();%s
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
@ -58,12 +69,22 @@ else
|
|||||||
vis = ""
|
vis = ""
|
||||||
end
|
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 = [[
|
local cppTemplate = [[
|
||||||
// Aurora Build Pipeline: Auto-generated Version File
|
// Aurora Build Pipeline: Auto-generated Version File
|
||||||
|
|
||||||
extern "C"
|
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,
|
||||||
vis, projectName,
|
vis, projectName,
|
||||||
|
vis, projectName,
|
||||||
cHeaderGitExt
|
cHeaderGitExt
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -92,10 +114,9 @@ if (not os.isfile(versionH)) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (not os.isfile(versionHPP)) then
|
if (not os.isfile(versionHPP)) then
|
||||||
io.writefile(versionHPP, cppTemplate)
|
io.writefile(versionHPP, string.format(cppTemplate, projectName))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local cheader = manifest.cheader or ""
|
local cheader = manifest.cheader or ""
|
||||||
|
|
||||||
local cTemplate = [[
|
local cTemplate = [[
|
||||||
@ -141,6 +162,11 @@ local cTemplate = [[
|
|||||||
|
|
||||||
return g_result = result;
|
return g_result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%suint32_ct Get%sGitVersionDetail()
|
||||||
|
{
|
||||||
|
return %su | (%s << 1u);
|
||||||
|
}
|
||||||
%s]]
|
%s]]
|
||||||
|
|
||||||
local hashTemplateA = [[
|
local hashTemplateA = [[
|
||||||
@ -181,8 +207,7 @@ if (includeGit) then
|
|||||||
%sconst char *Get%sCommitString()
|
%sconst char *Get%sCommitString()
|
||||||
{
|
{
|
||||||
return %s;
|
return %s;
|
||||||
}
|
}]]
|
||||||
]]
|
|
||||||
|
|
||||||
gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"")
|
gitFooter = string.format(gitFooter, vis, projectName, "\"" .. commitString .. "\"")
|
||||||
end
|
end
|
||||||
@ -194,6 +219,7 @@ local formattedCTemplate = string.format(cTemplate,
|
|||||||
vis, projectName, strMinor,
|
vis, projectName, strMinor,
|
||||||
vis, projectName, strMajor,
|
vis, projectName, strMajor,
|
||||||
vis, projectName, hashTemplate,
|
vis, projectName, hashTemplate,
|
||||||
|
vis, projectName, manifest.includeGit and "1" or "0", auBuild.shortGitCommit and "1" or "0",
|
||||||
gitFooter
|
gitFooter
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
local function feature()
|
local function feature()
|
||||||
files "Source/AuVersion.h"
|
local name = auGetCurrentProject()
|
||||||
files "Source/AuVersion.hpp"
|
files("Source/" .. name .. "Version.h")
|
||||||
files "Source/AuVersion.c"
|
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)
|
auAddBuildAction("pre", "lua", path.join(Aurora.Settings.sAbsScripts, "Features", "detail", "use-version-write-prjver-run.lua"), true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user