diff --git a/CMakeLists.txt b/CMakeLists.txt index ed08ca800..309a784e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,11 +47,35 @@ MESSAGE(STATUS "================================================================ SET(PKG_NAME "zetaglest") # read version - -FILE(READ ${PROJECT_SOURCE_DIR}/source/version.txt ZG_VERSION) -string(STRIP "${ZG_VERSION}" ZG_VERSION) -MESSAGE(STATUS "Detected ZetaGlest Version is [v${ZG_VERSION}] ") -add_definitions(-DZG_VERSION=\"${ZG_VERSION}\") +FILE(READ ${PROJECT_SOURCE_DIR}/source/glest_game/facilities/game_util.cpp ZG_VERSION_H_CONTENTS) +MESSAGE(STATUS "Determining version number system type to use:") +SET(Begin_otv_string "string glestVersionString") +STRING(REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\\.]*)(\\.)([^\\.]*)(\\.)([^\"\\.;]*)\";" _threePartMatch "${ZG_VERSION_H_CONTENTS}") +STRING(REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\\.]*)(\\.)([^\"\\.;]*)\";" _twoPartMatch "${ZG_VERSION_H_CONTENTS}") +STRING(REGEX MATCH "${Begin_otv_string}[ \t]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\"\\.;]*)\";" _onePartMatch "${ZG_VERSION_H_CONTENTS}") +IF(_threePartMatch) + MESSAGE(STATUS "** Trying 3 part versioning ") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\\.]*)\\.[^\\.]*\\..*" "\\1" VER_MAJOR "${_threePartMatch}") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*[0-9][^\\.]*\\.([^\\.]*)\\..*" "\\1" VER_MINOR "${_threePartMatch}") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*[0-9][^\\.]*\\.[^\\.]*\\.([^\"\\.;]*).*" "\\1" VER_PATCH "${_threePartMatch}") + SET(ZETAGLEST_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}") +ELSEIF(_twoPartMatch) + MESSAGE(STATUS "** Trying 2 part versioning ") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\\.]*)\\..*" "\\1" VER_MAJOR "${_twoPartMatch}") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*[0-9][^\\.]*\\.([^\"\\.;]*).*" "\\1" VER_MINOR "${_twoPartMatch}") + SET(VER_PATCH "0") + SET(ZETAGLEST_VERSION "${VER_MAJOR}.${VER_MINOR}") +ELSEIF(_onePartMatch) + MESSAGE(STATUS "** Trying 1 part versioning ") + STRING(REGEX REPLACE "[^=]*=[ \t]*\"[ \t]*v[ \t]*([0-9][^\"\\.;]*).*" "\\1" VER_MAJOR "${_onePartMatch}") + SET(VER_MINOR "0") + SET(VER_PATCH "0") + SET(ZETAGLEST_VERSION "${VER_MAJOR}") +ENDIF() +FOREACH(ver_var VER_MAJOR;VER_MINOR;VER_PATCH;ZETAGLEST_VERSION) + STRING(REGEX REPLACE "[ \t]" "" "${ver_var}" "${${ver_var}}") +ENDFOREACH() +MESSAGE(STATUS "Detected ZetaGlest Version is [v${ZETAGLEST_VERSION}] ") SET(PIC_FLAG "${PIC_FLAG} -fPIC") IF(WANT_STATIC_LIBS AND "${CMAKE_SIZEOF_VOID_P}" EQUAL "8") diff --git a/mk/macos/CMakeLists.txt b/mk/macos/CMakeLists.txt index f3d9e6661..2a143a8c3 100644 --- a/mk/macos/CMakeLists.txt +++ b/mk/macos/CMakeLists.txt @@ -37,7 +37,7 @@ include (InstallRequiredSystemLibraries) # Use bundle generator (OSX has 3 other options if you feel adventurous) SET(CPACK_GENERATOR "Bundle") SET(CPACK_BUNDLE_NAME "MegaGlest") -SET(CPACK_PACKAGE_FILE_NAME "MegaGlest-game-macos-${ZG_VERSION}") +SET(CPACK_PACKAGE_FILE_NAME "MegaGlest-game-macos-${ZETAGLEST_VERSION}") SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/mk/macos/bundle_resources/MegaGlest.icns") SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/mk/macos/bundle_resources/MegaGlest.icns") SET(CPACK_BUNDLE_STARTUP_COMMAND "${PROJECT_SOURCE_DIR}/mk/macos/bundle_resources/MegaGlest.sh") diff --git a/scripts/mg-version-synch.sh b/scripts/mg-version-synch.sh new file mode 100755 index 000000000..5a4ac7316 --- /dev/null +++ b/scripts/mg-version-synch.sh @@ -0,0 +1,124 @@ +#!/bin/sh +# Use this script to synchronize other scripts and installers with the version +# in mg-version.sh for a Version Release +# ---------------------------------------------------------------------------- +# Written by Mark Vejvoda +# Copyright (c) 2011-2015 Mark Vejvoda under GNU GPL v3.0+ + +CURRENTDIR="$(dirname "$(readlink -f "$0")")" +cd "$CURRENTDIR" +CURRENT_VERSION=`./mg-version.sh --version` +OLD_VERSION=`./mg-version.sh --oldversion_binary` +VERSION_INFO_FILE="$(dirname "$(readlink -f "$0")")/../../source/version.txt" +LastCompatibleSaveGameVersion="$(awk -F '=' '/^LastCompatibleSaveGameVersion =/ {print $2}' "$VERSION_INFO_FILE" | awk -F '"' '{print $2}')" +CurrYear="$(date +%y)" +MapeditorVersion="$CURRENT_VERSION" +G3dviewerVersion="$CURRENT_VERSION" +modifymore="yes" +echo +echo '===== Updating Game ======' +# const string glestVersionString = "v3.12-dev"; +echo 'Game version # before:' +grep -E '^const string glestVersionString = "[^"]*";$' ../../source/glest_game/facilities/game_util.cpp +sed -i 's/^const string glestVersionString = "[^"]*";$/const string glestVersionString = "v'$CURRENT_VERSION'";/' ../../source/glest_game/facilities/game_util.cpp +echo 'Game version # after:' +grep -E '^const string glestVersionString = "[^"]*";$' ../../source/glest_game/facilities/game_util.cpp +echo +echo 'Game Copyright date # before:' +grep -E 'Copyright 2010-20[0-9][0-9] The MegaGlest Team' ../../source/glest_game/facilities/game_util.cpp +sed -i 's/Copyright 2010-20[0-9][0-9] The MegaGlest Team/Copyright 2010-20'$CurrYear' The MegaGlest Team/' ../../source/glest_game/facilities/game_util.cpp +grep -E '© 2001-20[0-9][0-9] The MegaGlest Team' ../../mk/macos/bundle_resources/Info.plist.in +sed -i 's/© 2001-20[0-9][0-9] The MegaGlest Team/© 2001-20'$CurrYear' The MegaGlest Team/' ../../mk/macos/bundle_resources/Info.plist.in +echo 'Game Copyright date # after:' +grep -E 'Copyright 2010-20[0-9][0-9] The MegaGlest Team' ../../source/glest_game/facilities/game_util.cpp +grep -E '© 2001-20[0-9][0-9] The MegaGlest Team' ../../mk/macos/bundle_resources/Info.plist.in +echo +if [ "$modifymore" = "yes" ]; then + # const string lastCompatibleSaveGameVersionString = "v3.9.0"; + echo 'Compatible Save Game version # before:' + grep -E '^const string lastCompatibleSaveGameVersionString = "[^"]*";$' ../../source/glest_game/facilities/game_util.cpp + sed -i 's/^const string lastCompatibleSaveGameVersionString = "[^"]*";$/const string lastCompatibleSaveGameVersionString = "v'$LastCompatibleSaveGameVersion'";/' ../../source/glest_game/facilities/game_util.cpp + echo 'Compatible Save Game version # after:' + grep -E '^const string lastCompatibleSaveGameVersionString = "[^"]*";$' ../../source/glest_game/facilities/game_util.cpp + echo +fi +if [ "$modifymore" = "yes" ] && [ "$(git status >/dev/null 2>&1; echo "$?")" -eq "0" ]; then + # const string GIT_RawRev = "$4446.1a8673f$"; + GitCommitForRelease="`git rev-list HEAD --count`.`git log -1 --format=%h --abbrev=7`"; + echo 'GitCommitForRelease # before:' + grep -E '^GitCommitForRelease = "[^"]*";$' "$VERSION_INFO_FILE" + grep -E '^ const string GIT_RawRev = "\$[^"$]*\$";$' ../../source/glest_game/facilities/game_util.cpp + sed -i 's/^GitCommitForRelease = "[^"]*";$/GitCommitForRelease = "'$GitCommitForRelease'";/' "$VERSION_INFO_FILE" + sed -i 's/^ const string GIT_RawRev = "$[^"]*";$/ const string GIT_RawRev = "$'$GitCommitForRelease'$";/' ../../source/glest_game/facilities/game_util.cpp + echo 'GitCommitForRelease # after:' + grep -E '^GitCommitForRelease = "[^"]*";$' "$VERSION_INFO_FILE" + grep -E '^ const string GIT_RawRev = "\$[^"$]*\$";$' ../../source/glest_game/facilities/game_util.cpp +fi +echo +if [ "$modifymore" = "yes" ]; then + echo '===== Updating Mapeditor ======' + # const string mapeditorVersionString = "v1.6.1"; + echo 'Mapeditor version # before:' + grep -E '^const string mapeditorVersionString = "[^"]*";$' ../../source/glest_map_editor/main.cpp + sed -i 's/^const string mapeditorVersionString = "[^"]*";$/const string mapeditorVersionString = "v'$MapeditorVersion'";/' ../../source/glest_map_editor/main.cpp + echo 'Mapeditor version # after:' + grep -E '^const string mapeditorVersionString = "[^"]*";$' ../../source/glest_map_editor/main.cpp + echo + echo 'Mapeditor Copyright date # before:' + grep -E 'Copyright 2010-20[0-9][0-9] The MegaGlest Team' ../../source/glest_map_editor/main.cpp + sed -i 's/Copyright 2010-20[0-9][0-9] The MegaGlest Team/Copyright 2010-20'$CurrYear' The MegaGlest Team/' ../../source/glest_map_editor/main.cpp + echo 'Mapeditor Copyright date # after:' + grep -E 'Copyright 2010-20[0-9][0-9] The MegaGlest Team' ../../source/glest_map_editor/main.cpp + echo + echo '===== Updating G3dviewer ======' + # const string g3dviewerVersionString= "v1.3.6"; + echo 'G3dviewer version # before:' + grep -E '^const string g3dviewerVersionString= "[^"]*";$' ../../source/g3d_viewer/main.cpp + sed -i 's/^const string g3dviewerVersionString= "[^"]*";$/const string g3dviewerVersionString= "v'$G3dviewerVersion'";/' ../../source/g3d_viewer/main.cpp + echo 'G3dviewer version # after:' + grep -E '^const string g3dviewerVersionString= "[^"]*";$' ../../source/g3d_viewer/main.cpp +fi +echo +echo '===== Updating Linux Installer ======' +# local GAME_VERSION = "x.x.x"; +echo 'Linux Installer version # before:' +grep -E '^local GAME_VERSION = "[^"]*";$' tools-for-standalone-client/installer/scripts/config.lua +sed -i 's/^local GAME_VERSION = "[^"]*";$/local GAME_VERSION = "'$CURRENT_VERSION'";/' tools-for-standalone-client/installer/scripts/config.lua +echo 'Linux Installer version # after:' +grep -E '^local GAME_VERSION = "[^"]*";$' tools-for-standalone-client/installer/scripts/config.lua +echo +echo '===== Updating Windows Installer ======' +# !define APVER 3.6.0 +echo 'Windows Installer version # before:' +grep -E '^\!define APVER [^"]*$' ../windows/Installer/MegaGlestInstaller.nsi +sed -i 's/^\!define APVER [^"]*$/\!define APVER '$CURRENT_VERSION'/' ../windows/Installer/MegaGlestInstaller.nsi +echo 'Windows Installer version # after:' +grep -E '^\!define APVER [^"]*$' ../windows/Installer/MegaGlestInstaller.nsi +echo +if [ "$modifymore" = "yes" ]; then + echo 'Windows Installer version # before:' + grep -E '^\!define APVER_OLD [^"]*$' ../windows/Installer/MegaGlestInstaller.nsi + sed -i 's/^\!define APVER_OLD [^"]*$/\!define APVER_OLD '$OLD_VERSION'/' ../windows/Installer/MegaGlestInstaller.nsi + echo 'Windows Installer version # after:' + grep -E '^\!define APVER_OLD [^"]*$' ../windows/Installer/MegaGlestInstaller.nsi + echo + echo '===== Updating Windows Updater ======' + echo 'Windows Updater version # before:' + grep -E '^\!define APVER [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + sed -i 's/^\!define APVER [^"]*$/\!define APVER '$CURRENT_VERSION'/' ../windows/Installer/MegaGlestUpdater.nsi + echo 'Windows Updater version # after:' + grep -E '^\!define APVER [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + echo + echo 'Windows Updater version # before:' + grep -E '^\!define APVER_OLD [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + sed -i 's/^\!define APVER_OLD [^"]*$/\!define APVER_OLD '$OLD_VERSION'/' ../windows/Installer/MegaGlestUpdater.nsi + echo 'Windows Updater version # after:' + grep -E '^\!define APVER_OLD [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + echo + echo 'Windows Updater version # before:' + grep -E '^\!define APVER_UPDATE [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + sed -i 's/^\!define APVER_UPDATE [^"]*$/\!define APVER_UPDATE '$CURRENT_VERSION'/' ../windows/Installer/MegaGlestUpdater.nsi + echo 'Windows Updater version # after:' + grep -E '^\!define APVER_UPDATE [^"]*$' ../windows/Installer/MegaGlestUpdater.nsi + echo +fi diff --git a/scripts/mg-version.sh b/scripts/mg-version.sh new file mode 100755 index 000000000..53a0d3e0b --- /dev/null +++ b/scripts/mg-version.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Use this script to idenitfy previous and current Version for a Version Release +# ---------------------------------------------------------------------------- +# Written by Mark Vejvoda +# Copyright (c) 2011 Mark Vejvoda under GNU GPL v3.0+ + +KERNEL="$(uname -s | tr '[A-Z]' '[a-z]')" +if [ "$KERNEL" = "darwin" ]; then + CURRENTDIR="$(cd "$(dirname "$0")"; pwd)" +else + CURRENTDIR="$(dirname "$(readlink -f "$0")")" +fi +VERSION_INFO_FILE="$CURRENTDIR/../../source/version.txt" +OLD_MG_VERSION="$(awk -F '=' '/^OldReleaseGameVersion =/ {print $2}' "$VERSION_INFO_FILE" | awk -F '"' '{print $2}')" +OLD_MG_VERSION_BINARY="$OLD_MG_VERSION" +MG_VERSION="$(awk -F '=' '/^CurrentGameVersion =/ {print $2}' "$VERSION_INFO_FILE" | awk -F '"' '{print $2}')" + +if [ "$1" = "--oldversion" ]; then + echo "$OLD_MG_VERSION" +elif [ "$1" = "--oldversion_binary" ]; then + echo "$OLD_MG_VERSION_BINARY" +elif [ "$1" = "--version" ]; then + echo "$MG_VERSION" +fi diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 2a4663f32..b44897205 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -73,7 +73,7 @@ const char *folderDelimiter = "/"; //int GameConstants::updateFps= 40; //int GameConstants::cameraFps= 100; -const string g3dviewerVersionString = ZG_VERSION; +const string g3dviewerVersionString = "v0.8.01"; // Because g3d should always support alpha transparency string fileFormat = "png"; diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 84ef177e9..eb80c0ea8 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -44,7 +44,7 @@ namespace Glest { // !! Use minor versions !! Only major and minor version control compatibility! // typical version numbers look like this: v0.8.01 // don't forget to update file: source/version.txt - const string glestVersionString = ZG_VERSION; + const string glestVersionString = "v0.8.02"; const string lastCompatibleSaveGameVersionString = "v0.8.01"; string getCrashDumpFileName() { diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index 2352bdfd0..2128f687c 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -60,7 +60,7 @@ namespace Glest { namespace MapEditor { - const string mapeditorVersionString = ZG_VERSION; + const string mapeditorVersionString = "v0.8.01"; const string MainWindow::winHeader = "ZetaGlest Map Editor " + mapeditorVersionString; // =============================================== diff --git a/source/version.txt b/source/version.txt index 76cead29e..f414d8e33 100644 --- a/source/version.txt +++ b/source/version.txt @@ -1 +1,12 @@ -0.8.02 +# How it currently works? +# Set version here (only here) and just start mk/linux/mg-version-synch.sh script. +# Versions will be updated everywhere automatically. +# Then you should commit changed files and that's all. + +CurrentGameVersion = "0.8.02"; + +OldReleaseGameVersion = "0.8.01"; +LastCompatibleSaveGameVersion = "0.8.01"; + +#This property is deprecated. Do not use +GitCommitForRelease = "5733.147264d";