mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-18 23:32:54 +00:00
chore: write header with git version
This commit is contained in:
parent
50d4282b54
commit
7919683748
@ -3,6 +3,7 @@ include "tools/scripts/including.lua"
|
||||
include "tools/scripts/linking.lua"
|
||||
include "tools/scripts/options.lua"
|
||||
include "tools/scripts/platform.lua"
|
||||
include "tools/scripts/version.lua"
|
||||
|
||||
-- ==================
|
||||
-- Workspace
|
||||
@ -63,6 +64,13 @@ workspace "OpenAssetTools"
|
||||
"__STDC_WANT_LIB_EXT1__=1",
|
||||
"_CRT_SECURE_NO_WARNINGS"
|
||||
}
|
||||
|
||||
-- Write the current version to a header
|
||||
-- This is better than adding it as macro here since changing a global macro would cause a full rebuild
|
||||
WriteVersionHeader()
|
||||
includedirs {
|
||||
GetVersionHeaderFolder()
|
||||
}
|
||||
|
||||
filter "options:debug-structureddatadef"
|
||||
defines { "STRUCTUREDDATADEF_DEBUG" }
|
||||
|
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
|
Loading…
x
Reference in New Issue
Block a user