mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-09 22:38:06 -05:00
chore: write header with git version
This commit is contained in:
36
tools/scripts/version.lua
Normal file
36
tools/scripts/version.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local BuildSubFolderFolder = "premake"
|
||||
local HeaderFileName = "GitVersion.h"
|
||||
|
||||
function GetGitVersion()
|
||||
result, errorCode = os.outputof("git describe --tags")
|
||||
|
||||
if errorCode == 0 then
|
||||
return result
|
||||
end
|
||||
|
||||
return "Unknown"
|
||||
end
|
||||
|
||||
function GetVersionHeaderFolder()
|
||||
return path.join(BuildFolder(), BuildSubFolderFolder)
|
||||
end
|
||||
|
||||
function WriteVersionHeader()
|
||||
local folder = GetVersionHeaderFolder()
|
||||
local file = path.join(folder, HeaderFileName)
|
||||
local content = string.format([[
|
||||
#pragma once
|
||||
|
||||
#define GIT_VERSION "%s"
|
||||
]], GetGitVersion())
|
||||
|
||||
if os.isdir(folder) ~= True then
|
||||
os.mkdir(folder)
|
||||
end
|
||||
|
||||
local ok, err = os.writefile_ifnotequal(content, file)
|
||||
|
||||
if ok == -1 then
|
||||
error("Could not create version file: " .. err)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user