mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Show git hash in version string at top left corner of window
This commit is contained in:
parent
372d638ec1
commit
8bc7ea61b9
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,6 +31,7 @@ CMakeFiles/*
|
||||
src/CMakeFiles/*
|
||||
src/Makefile
|
||||
src/cmake_config.h
|
||||
src/cmake_config_githash.h
|
||||
src/cmake_install.cmake
|
||||
src/script/CMakeFiles/*
|
||||
src/script/common/CMakeFiles/*
|
||||
|
@ -15,6 +15,9 @@ set(VERSION_MINOR 4)
|
||||
set(VERSION_PATCH 7)
|
||||
if(VERSION_EXTRA)
|
||||
set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
|
||||
else()
|
||||
# Comment the following line during release
|
||||
set(VERSION_PATCH ${VERSION_PATCH}-dev)
|
||||
endif()
|
||||
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
|
||||
|
20
cmake/Modules/GenerateVersion.cmake
Normal file
20
cmake/Modules/GenerateVersion.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
# Always run during 'make'
|
||||
|
||||
if(VERSION_EXTRA)
|
||||
set(VERSION_GITHASH "${VERSION_STRING}")
|
||||
else(VERSION_EXTRA)
|
||||
execute_process(COMMAND git describe --always --tag --dirty
|
||||
WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET)
|
||||
|
||||
if(VERSION_GITHASH)
|
||||
message(STATUS "*** Detected git version ${VERSION_GITHASH} ***")
|
||||
else()
|
||||
set(VERSION_GITHASH "${VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${GENERATE_VERSION_SOURCE_DIR}/cmake_config_githash.h.in
|
||||
${GENERATE_VERSION_BINARY_DIR}/cmake_config_githash.h)
|
@ -225,11 +225,21 @@ configure_file(
|
||||
"${PROJECT_BINARY_DIR}/cmake_config.h"
|
||||
)
|
||||
|
||||
# Add a target that always rebuilds cmake_config_githash.h
|
||||
add_custom_target(GenerateVersion
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "GENERATE_VERSION_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
-D "GENERATE_VERSION_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
|
||||
-D "VERSION_STRING=${VERSION_STRING}"
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateVersion.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_subdirectory(jthread)
|
||||
add_subdirectory(script)
|
||||
add_subdirectory(util)
|
||||
|
||||
set(common_SRCS
|
||||
version.cpp
|
||||
rollback_interface.cpp
|
||||
rollback.cpp
|
||||
genericobject.cpp
|
||||
@ -406,6 +416,7 @@ set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
|
||||
|
||||
if(BUILD_CLIENT)
|
||||
add_executable(${PROJECT_NAME} ${minetest_SRCS})
|
||||
add_dependencies(${PROJECT_NAME} GenerateVersion)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
${ZLIB_LIBRARIES}
|
||||
@ -444,6 +455,7 @@ endif(BUILD_CLIENT)
|
||||
|
||||
if(BUILD_SERVER)
|
||||
add_executable(${PROJECT_NAME}server ${minetestserver_SRCS})
|
||||
add_dependencies(${PROJECT_NAME}server GenerateVersion)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}server
|
||||
${ZLIB_LIBRARIES}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#else
|
||||
#define CMAKE_BUILD_TYPE "Debug"
|
||||
#endif
|
||||
#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ USE_CURL=@USE_CURL@ USE_FREETYPE=@USE_FREETYPE@ USE_LUAJIT=@USE_LUAJIT@ STATIC_SHAREDIR=@SHAREDIR@"
|
||||
#define CMAKE_BUILD_INFO "BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ USE_CURL=@USE_CURL@ USE_FREETYPE=@USE_FREETYPE@ USE_LUAJIT=@USE_LUAJIT@ STATIC_SHAREDIR=@SHAREDIR@"
|
||||
|
||||
#endif
|
||||
|
||||
|
10
src/cmake_config_githash.h.in
Normal file
10
src/cmake_config_githash.h.in
Normal file
@ -0,0 +1,10 @@
|
||||
// Filled in by the build system
|
||||
// Separated from cmake_config.h to avoid excessive rebuilds on every commit
|
||||
|
||||
#ifndef CMAKE_CONFIG_GITHASH_H
|
||||
#define CMAKE_CONFIG_GITHASH_H
|
||||
|
||||
#define CMAKE_VERSION_GITHASH "@VERSION_GITHASH@"
|
||||
|
||||
#endif
|
||||
|
@ -7,22 +7,18 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#define PROJECT_NAME "Minetest"
|
||||
#define VERSION_STRING "unknown"
|
||||
#define RUN_IN_PLACE 0
|
||||
#define USE_GETTEXT 0
|
||||
#define USE_SOUND 0
|
||||
#define USE_CURL 0
|
||||
#define USE_FREETYPE 0
|
||||
#define STATIC_SHAREDIR ""
|
||||
#define BUILD_INFO "non-cmake"
|
||||
#define USE_LEVELDB 0
|
||||
|
||||
#ifdef USE_CMAKE_CONFIG_H
|
||||
#include "cmake_config.h"
|
||||
#undef PROJECT_NAME
|
||||
#define PROJECT_NAME CMAKE_PROJECT_NAME
|
||||
#undef VERSION_STRING
|
||||
#define VERSION_STRING CMAKE_VERSION_STRING
|
||||
#undef RUN_IN_PLACE
|
||||
#define RUN_IN_PLACE CMAKE_RUN_IN_PLACE
|
||||
#undef USE_GETTEXT
|
||||
@ -35,8 +31,6 @@
|
||||
#define USE_FREETYPE CMAKE_USE_FREETYPE
|
||||
#undef STATIC_SHAREDIR
|
||||
#define STATIC_SHAREDIR CMAKE_STATIC_SHAREDIR
|
||||
#undef BUILD_INFO
|
||||
#define BUILD_INFO CMAKE_BUILD_INFO
|
||||
#undef USE_LEVELDB
|
||||
#define USE_LEVELDB CMAKE_USE_LEVELDB
|
||||
#endif
|
||||
|
10
src/game.cpp
10
src/game.cpp
@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "tool.h"
|
||||
#include "guiChatConsole.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
#include "clouds.h"
|
||||
#include "particles.h"
|
||||
#include "camera.h"
|
||||
@ -2963,9 +2964,6 @@ void the_game(
|
||||
|
||||
//TimeTaker guiupdatetimer("Gui updating");
|
||||
|
||||
const char program_name_and_version[] =
|
||||
"Minetest " VERSION_STRING;
|
||||
|
||||
if(show_debug)
|
||||
{
|
||||
static float drawtime_avg = 0;
|
||||
@ -2979,7 +2977,7 @@ void the_game(
|
||||
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
os<<std::fixed
|
||||
<<program_name_and_version
|
||||
<<"Minetest "<<minetest_version_hash
|
||||
<<" (R: range_all="<<draw_control.range_all<<")"
|
||||
<<std::setprecision(0)
|
||||
<<" drawtime = "<<drawtime_avg
|
||||
@ -2995,7 +2993,9 @@ void the_game(
|
||||
}
|
||||
else if(show_hud || show_chat)
|
||||
{
|
||||
guitext->setText(narrow_to_wide(program_name_and_version).c_str());
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
os<<"Minetest "<<minetest_version_hash;
|
||||
guitext->setText(narrow_to_wide(os.str()).c_str());
|
||||
guitext->setVisible(true);
|
||||
}
|
||||
else
|
||||
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
#include "scripting_mainmenu.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
#include "porting.h"
|
||||
#include "filesys.h"
|
||||
#include "main.h"
|
||||
@ -157,7 +158,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
|
||||
//create topleft header
|
||||
core::rect<s32> rect(0, 0, 500, 40);
|
||||
rect += v2s32(4, 0);
|
||||
std::string t = "Minetest " VERSION_STRING;
|
||||
std::string t = std::string("Minetest ") + minetest_version_hash;
|
||||
|
||||
m_irr_toplefttext =
|
||||
m_device->getGUIEnvironment()->addStaticText(narrow_to_wide(t).c_str(),
|
||||
@ -553,7 +554,7 @@ bool GUIEngine::downloadFile(std::string url,std::string target) {
|
||||
|
||||
/******************************************************************************/
|
||||
void GUIEngine::setTopleftText(std::string append) {
|
||||
std::string toset = "Minetest " VERSION_STRING;
|
||||
std::string toset = std::string("Minetest ") + minetest_version_hash;
|
||||
|
||||
if (append != "") {
|
||||
toset += " / ";
|
||||
|
@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "serialization.h"
|
||||
#include "porting.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
#include "main.h"
|
||||
#include <IGUICheckBox.h>
|
||||
#include <IGUIEditBox.h>
|
||||
@ -195,7 +196,7 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
|
||||
|
||||
std::ostringstream os;
|
||||
os<<"Minetest\n";
|
||||
os<<BUILD_INFO<<"\n";
|
||||
os<<minetest_build_info<<"\n";
|
||||
os<<"path_user = "<<wrap_rows(porting::path_user, 20)<<"\n";
|
||||
|
||||
Environment->addStaticText(narrow_to_wide(os.str()).c_str(), rect, false, true, this, 259);
|
||||
|
@ -58,6 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "guiMessageMenu.h"
|
||||
#include "filesys.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
#include "guiMainMenu.h"
|
||||
#include "game.h"
|
||||
#include "keycode.h"
|
||||
@ -903,7 +904,7 @@ int main(int argc, char *argv[])
|
||||
// Print startup message
|
||||
infostream<<PROJECT_NAME<<
|
||||
" "<<_("with")<<" SER_FMT_VER_HIGHEST_READ="<<(int)SER_FMT_VER_HIGHEST_READ
|
||||
<<", "<<BUILD_INFO
|
||||
<<", "<<minetest_build_info
|
||||
<<std::endl;
|
||||
|
||||
/*
|
||||
|
@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "guiKeyChangeMenu.h"
|
||||
#include "guiFileSelectMenu.h"
|
||||
#include "subgame.h"
|
||||
#include "version.h"
|
||||
#include "porting.h"
|
||||
#include "filesys.h"
|
||||
#include "convert_json.h"
|
||||
@ -923,7 +924,7 @@ int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_get_version(lua_State *L)
|
||||
{
|
||||
lua_pushstring(L,VERSION_STRING);
|
||||
lua_pushstring(L, minetest_version_simple);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "constants.h"
|
||||
#include "voxel.h"
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
#include "filesys.h"
|
||||
#include "mapblock.h"
|
||||
#include "serverobject.h"
|
||||
@ -1855,7 +1856,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
DenyAccess(peer_id, std::wstring(
|
||||
L"Your client's version is not supported.\n"
|
||||
L"Server version is ")
|
||||
+ narrow_to_wide(VERSION_STRING) + L"."
|
||||
+ narrow_to_wide(minetest_version_simple) + L"."
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -1903,7 +1904,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
DenyAccess(peer_id, std::wstring(
|
||||
L"Your client's version is not supported.\n"
|
||||
L"Server version is ")
|
||||
+ narrow_to_wide(VERSION_STRING) + L",\n"
|
||||
+ narrow_to_wide(minetest_version_simple) + L",\n"
|
||||
+ L"server's PROTOCOL_VERSION is "
|
||||
+ narrow_to_wide(itos(SERVER_PROTOCOL_VERSION_MIN))
|
||||
+ L"..."
|
||||
@ -1925,7 +1926,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
DenyAccess(peer_id, std::wstring(
|
||||
L"Your client's version is not supported.\n"
|
||||
L"Server version is ")
|
||||
+ narrow_to_wide(VERSION_STRING) + L",\n"
|
||||
+ narrow_to_wide(minetest_version_simple) + L",\n"
|
||||
+ L"server's PROTOCOL_VERSION (strict) is "
|
||||
+ narrow_to_wide(itos(LATEST_PROTOCOL_VERSION))
|
||||
+ L", client's PROTOCOL_VERSION is "
|
||||
@ -4823,7 +4824,7 @@ std::wstring Server::getStatusString()
|
||||
std::wostringstream os(std::ios_base::binary);
|
||||
os<<L"# Server: ";
|
||||
// Version
|
||||
os<<L"version="<<narrow_to_wide(VERSION_STRING);
|
||||
os<<L"version="<<narrow_to_wide(minetest_version_simple);
|
||||
// Uptime
|
||||
os<<L", uptime="<<m_uptime.get();
|
||||
// Max lag estimate
|
||||
|
@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "version.h"
|
||||
#include "main.h" // for g_settings
|
||||
#include "settings.h"
|
||||
#include "serverlist.h"
|
||||
@ -202,7 +203,7 @@ void sendAnnounce(std::string action, u16 clients, double uptime, std::string ga
|
||||
if (action != "delete") {
|
||||
server["name"] = g_settings->get("server_name");
|
||||
server["description"] = g_settings->get("server_description");
|
||||
server["version"] = VERSION_STRING;
|
||||
server["version"] = minetest_version_simple;
|
||||
server["url"] = g_settings->get("server_url");
|
||||
server["creative"] = g_settings->get("creative_mode");
|
||||
server["damage"] = g_settings->get("enable_damage");
|
||||
|
39
src/version.cpp
Normal file
39
src/version.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Minetest
|
||||
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "version.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_CMAKE_CONFIG_H
|
||||
|
||||
#include "cmake_config_githash.h"
|
||||
|
||||
const char *minetest_version_simple = CMAKE_VERSION_STRING;
|
||||
const char *minetest_version_hash = CMAKE_VERSION_GITHASH;
|
||||
const char *minetest_build_info =
|
||||
"VER=" CMAKE_VERSION_GITHASH " " CMAKE_BUILD_INFO;
|
||||
|
||||
#else
|
||||
|
||||
const char *minetest_version_simple = "unknown";
|
||||
const char *minetest_version_hash = "unknown";
|
||||
const char *minetest_build_info = "non-cmake";
|
||||
|
||||
#endif
|
||||
|
30
src/version.h
Normal file
30
src/version.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Minetest
|
||||
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef VERSION_HEADER
|
||||
#define VERSION_HEADER
|
||||
|
||||
#include "config.h"
|
||||
|
||||
extern const char *minetest_version_simple;
|
||||
extern const char *minetest_version_hash;
|
||||
extern const char *minetest_build_info;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user