Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git to retrieve version instead of manually change PREMAKE_VERSION. #2405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:tags=true)$
25 changes: 25 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@
-- 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:tags=true)$" then
git_tag = nil
end
if git_tag and git_tag:startswith('v') then -- tags use v5.x.x-xxx format whereas premake uses 5.x.x-xxx
git_tag = git_tag:strsub(2)
end
print("Current git tag: ", git_tag)
end

solution "Premake5"
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )
Expand Down Expand Up @@ -278,6 +299,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
Loading