Skip to content

Commit 92335d7

Browse files
committed
Rework /version, don't show preview and ignored releases
1 parent 9aa4c76 commit 92335d7

4 files changed

Lines changed: 58 additions & 12 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ lib/astc-encoder
9393
lib/shaderc
9494

9595
.DS_Store
96+
97+
# Auto-generated files
98+
src/utils/version.hpp

CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ execute_process(
99

1010
# Get the latest abbreviated commit hash of the working branch
1111
execute_process(
12-
COMMAND git --no-pager describe --tags --always --dirty
12+
COMMAND git --no-pager describe --tags --always --exclude "preview" --exclude "ign-*" --dirty
1313
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
14-
OUTPUT_VARIABLE GIT_COMMIT_HASH
14+
OUTPUT_VARIABLE GIT_VERSION
1515
OUTPUT_STRIP_TRAILING_WHITESPACE
1616
)
1717

18+
message(STATUS "Configuring file from: ${CMAKE_SOURCE_DIR}/src/utils/version.hpp.in")
19+
message(STATUS "Output file: ${CMAKE_SOURCE_DIR}/src/utils/version.hpp")
20+
21+
configure_file(
22+
${CMAKE_SOURCE_DIR}/src/utils/version.hpp.in
23+
${CMAKE_SOURCE_DIR}/src/utils/version.hpp
24+
@ONLY)
25+
26+
include_directories(${CMAKE_BINARY_DIR}/generated)
27+
1828
# root CMakeLists for the SuperTuxKart project
1929
project(SuperTuxKart)
2030
set(PROJECT_VERSION "git")
@@ -655,9 +665,6 @@ else()
655665
endif()
656666
endif()
657667
658-
target_compile_definitions(supertuxkart PRIVATE "-DGIT_BRANCH=\"${GIT_BRANCH}\"")
659-
target_compile_definitions(supertuxkart PRIVATE "-DGIT_VERSION=\"${GIT_COMMIT_HASH}\"")
660-
661668
# check if linking against libatomic is required
662669
include(CheckCXXSourceCompiles)
663670
check_cxx_source_compiles("

src/network/protocols/command_manager.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "utils/string_utils.hpp"
5151
#include "utils/team_manager.hpp"
5252
#include "utils/tournament.hpp"
53+
#include "utils/version.hpp"
5354

5455
#include <algorithm>
5556
#include <fstream>
@@ -623,13 +624,12 @@ void CommandManager::initCommands()
623624

624625
addTextResponse("description", getSettings()->getMotd());
625626
addTextResponse("moreinfo", getSettings()->getHelpMessage());
626-
std::string version = "1.3 k 210fff beta";
627-
#ifdef GIT_VERSION
628-
version = std::string(GIT_VERSION);
629-
#ifdef GIT_BRANCH
630-
version += ", branch " + std::string(GIT_BRANCH);
631-
#endif
632-
#endif
627+
628+
std::string version = Version::version();
629+
std::string branch = Version::branch();
630+
if (!branch.empty())
631+
version += ", branch " + branch;
632+
633633
addTextResponse("version", version);
634634
addTextResponse("clear", std::string(30, '\n'));
635635

src/utils/version.hpp.in

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// SuperTuxKart - a fun racing game with go-kart
3+
// Copyright (C) 2025 kimden
4+
//
5+
// This program is free software; you can redistribute it and/or
6+
// modify it under the terms of the GNU General Public License
7+
// as published by the Free Software Foundation; either version 3
8+
// of the License, or (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program; if not, write to the Free Software
17+
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18+
19+
// version.hpp is generated from version.hpp.in.
20+
// While making changes, make sure to edit the correct file.
21+
22+
#ifndef VERSION_HPP
23+
#define VERSION_HPP
24+
25+
#define GIT_BRANCH "@GIT_BRANCH@"
26+
#define GIT_VERSION "@GIT_VERSION@"
27+
28+
#include <string>
29+
30+
struct Version
31+
{
32+
static std::string branch() { return GIT_BRANCH; }
33+
static std::string version() { return GIT_VERSION; }
34+
};
35+
36+
#endif // VERSION_HPP

0 commit comments

Comments
 (0)