Skip to content

Commit

Permalink
Use git to retrieve version instead of manually change `PREMAKE_VERSI…
Browse files Browse the repository at this point in the history
…ON`.
  • Loading branch information
Jarod42 committed Jan 2, 2025
1 parent eb418ab commit 4a5a9ff
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Bootstrap.bat text eol=crlf
git-tags.txt export-subst
1 change: 1 addition & 0 deletions git-tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$Format:%(describe)$
22 changes: 22 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,24 @@
-- symbols "On"
--

local function retrieve_git_tag()
local git_tag, errorCode = os.outputof("git describe --tag --exact-match")
if errorCode == 0 then
return git_tag
else
return nil
end
end

if premake.action.isConfigurable() then
local git_tag = retrieve_git_tag() or io.readfile("git-tags.txt")

if git_tag == "$Format:%(describe)$" then
git_tag = nil
end
print("Current git tag: ", git_tag)
end

solution "Premake5"
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )
Expand Down Expand Up @@ -278,6 +296,10 @@
"binmodules/**.*"
}

if git_tag then
defines { "PREMAKE_VERSION=" .. git_tag }
end

filter { "options:lua-src=contrib" }
includedirs { "contrib/lua/src", "contrib/luashim" }
links { "lua-lib" }
Expand Down
5 changes: 4 additions & 1 deletion src/host/premake.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
#include <stdint.h>
#include <stdlib.h>

#define PREMAKE_VERSION "5.0.0-dev"
#ifndef PREMAKE_VERSION
# define PREMAKE_VERSION "5.0.0-dev"
#endif

#define PREMAKE_COPYRIGHT "Copyright (C) 2002-2024 Jess Perkins and the Premake Project"
#define PREMAKE_PROJECT_URL "https://github.com/premake/premake-core/wiki"

Expand Down

0 comments on commit 4a5a9ff

Please sign in to comment.