aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt12
-rw-r--r--src/cmake_config.h.in2
-rw-r--r--src/cmake_config_githash.h.in10
-rw-r--r--src/config.h6
-rw-r--r--src/game.cpp10
-rw-r--r--src/guiEngine.cpp5
-rw-r--r--src/guiPauseMenu.cpp3
-rw-r--r--src/main.cpp3
-rw-r--r--src/script/lua_api/l_mainmenu.cpp3
-rw-r--r--src/server.cpp9
-rw-r--r--src/serverlist.cpp3
-rw-r--r--src/version.cpp39
-rw-r--r--src/version.h30
13 files changed, 113 insertions, 22 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8a5212dca..4d99f5acd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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}
diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in
index c83df8e47..7cc2fb99e 100644
--- a/src/cmake_config.h.in
+++ b/src/cmake_config.h.in
@@ -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
diff --git a/src/cmake_config_githash.h.in b/src/cmake_config_githash.h.in
new file mode 100644
index 000000000..4d5fcd60f
--- /dev/null
+++ b/src/cmake_config_githash.h.in
@@ -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
+
diff --git a/src/config.h b/src/config.h
index 3cb59e619..652c9008a 100644
--- a/src/config.h
+++ b/src/config.h
@@ -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
diff --git a/src/game.cpp b/src/game.cpp
index 851f5dd9d..71a578a65 100644
--- a/src/game.cpp
+++ b/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
diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp
index 547f393a4..ac19274c3 100644
--- a/src/guiEngine.cpp
+++ b/src/guiEngine.cpp
@@ -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 += " / ";
diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp
index f5d323a9b..ba103b740 100644
--- a/src/guiPauseMenu.cpp
+++ b/src/guiPauseMenu.cpp
@@ -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);
diff --git a/src/main.cpp b/src/main.cpp
index f34e24abc..10547b711 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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;
/*
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 55376690e..ff0d52774 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -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;
}
diff --git a/src/server.cpp b/src/server.cpp
index 492ad907b..c144be1ba 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -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
diff --git a/src/serverlist.cpp b/src/serverlist.cpp
index 4db5f3ecd..908f048cb 100644
--- a/src/serverlist.cpp
+++ b/src/serverlist.cpp
@@ -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");
diff --git a/src/version.cpp b/src/version.cpp
new file mode 100644
index 000000000..e5de8a61e
--- /dev/null
+++ b/src/version.cpp
@@ -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
+
diff --git a/src/version.h b/src/version.h
new file mode 100644
index 000000000..0143d91a4
--- /dev/null
+++ b/src/version.h
@@ -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
+