diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b8acb95..ec5b9756 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,6 +264,7 @@ add_custom_target( -DAPP_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -DCORE_SOURCE_DIR=${DAEMON_DIR} -DCPP_INT_FILE=${VERSION_INFO_DIR}/version_info.cpp.in + -DBUILD_VERSION=${BUILD_VERSION} -P ${CMAKE_SCRIPTS_DIR}/generate_version_info.cmake ) list(APPEND CLIENT_INCLUDE_DIRS ${VERSION_INFO_DIR}) @@ -377,7 +378,6 @@ set(COMMON_HEADERS ${APP_SRC_DIR}/appversionmanager.h ${APP_SRC_DIR}/utils.h ${APP_SRC_DIR}/bannedlistmodel.h - ${APP_SRC_DIR}/version.h ${APP_SRC_DIR}/accountlistmodel.h ${APP_SRC_DIR}/instancemanager.h ${APP_SRC_DIR}/connectivitymonitor.h diff --git a/extras/build/cmake/generate_version_info.cmake b/extras/build/cmake/generate_version_info.cmake index ad753962..01c0dc85 100644 --- a/extras/build/cmake/generate_version_info.cmake +++ b/extras/build/cmake/generate_version_info.cmake @@ -24,6 +24,7 @@ set(CMAKE_CURRENT_BINARY_DIR ${APP_BINARY_DIR}) # Generate the version string for the application and core configure_version_string(${APP_SOURCE_DIR} APP_VERSION_STRING) configure_version_string(${CORE_SOURCE_DIR} CORE_VERSION_STRING) +set(BUILD_VERSION_STRING ${BUILD_VERSION}) # Get output file names with the .in extension removed get_filename_component(VERSION_CPP_FILENAME ${CPP_INT_FILE} NAME_WE) diff --git a/extras/scripts/build-windows.py b/extras/scripts/build-windows.py index 2c654e25..3bdd4091 100644 --- a/extras/scripts/build-windows.py +++ b/extras/scripts/build-windows.py @@ -263,7 +263,7 @@ def cmake_build(config_str, env_vars, cmake_build_dir): return True -def build(config_str, qt_dir, tests, enable_crash_reports, crash_report_url=None): +def build(config_str, qt_dir, tests, build_version, enable_crash_reports, crash_report_url=None): """Use cmake to build the project.""" print("Building with Qt at " + qt_dir) @@ -294,6 +294,9 @@ def build(config_str, qt_dir, tests, enable_crash_reports, crash_report_url=None else: cmake_options.append("-DENABLE_CRASHREPORTS=OFF") + if build_version: + cmake_options.append("-DBUILD_VERSION=" + build_version) + # Make sure the build directory exists. if not os.path.exists(build_dir): os.makedirs(build_dir) @@ -470,6 +473,8 @@ def parse_args(): help='Sets the Qt root path') parser.add_argument( "-a", "--arch", default="x64", help="Sets the build architecture") + parser.add_argument( + "--build-version", help="Sets the build version string used for defining app build version") parser.add_argument( "-t", "--tests", action="store_true", help="Build and run tests") parser.add_argument( @@ -552,6 +557,7 @@ def main(): def do_build(do_tests): if not parsed_args.skip_build: build(config_str, parsed_args.qt, do_tests, + parsed_args.build_version, parsed_args.enable_crash_reports, parsed_args.crash_report_url) if not parsed_args.skip_deploy: diff --git a/src/app/appversionmanager.cpp b/src/app/appversionmanager.cpp index 3a3a2b80..5494fa8a 100644 --- a/src/app/appversionmanager.cpp +++ b/src/app/appversionmanager.cpp @@ -18,7 +18,7 @@ #include "appversionmanager.h" #include "lrcinstance.h" -#include "version.h" +#include "version_info.h" #include #include @@ -73,7 +73,7 @@ struct AppVersionManager::Impl : public QObject Q_EMIT parent_.updateCheckReplyReceived(false); return; } - auto currentVersion = QString(VERSION_STRING).toULongLong(); + auto currentVersion = BUILD_VERSION_STRING.toULongLong(); auto latestVersion = latestVersionString.toULongLong(); const QString channelStr = isBeta ? "beta" : "stable"; const auto newVersionFound = latestVersion > currentVersion; diff --git a/src/app/crashreportclient.h b/src/app/crashreportclient.h index 0118ab7c..1fb4e4da 100644 --- a/src/app/crashreportclient.h +++ b/src/app/crashreportclient.h @@ -17,7 +17,6 @@ #pragma once -#include "version.h" #include "version_info.h" #include @@ -108,7 +107,7 @@ protected: {"platform", QSysInfo::prettyProductName() + "_" + QSysInfo::currentCpuArchitecture()}, {"client_sha", APP_VERSION_STRING}, {"jamicore_sha", CORE_VERSION_STRING}, - {"build_id", QString(VERSION_STRING)}, + {"build_id", BUILD_VERSION_STRING}, #if defined(Q_OS_WIN) && defined(BETA) {"build_variant", "beta"}, #endif diff --git a/src/app/main.cpp b/src/app/main.cpp index 224c642c..5149a78b 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -17,7 +17,7 @@ #include "mainapplication.h" #include "instancemanager.h" -#include "version.h" +#include "version_info.h" #if defined(Q_OS_MACOS) #include #endif @@ -66,7 +66,7 @@ main(int argc, char* argv[]) QApplication::setApplicationName(QStringLiteral("Jami")); QApplication::setOrganizationDomain(QStringLiteral("jami.net")); QApplication::setQuitOnLastWindowClosed(false); - QCoreApplication::setApplicationVersion(QString(VERSION_STRING)); + QCoreApplication::setApplicationVersion(BUILD_VERSION_STRING); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QApplication::setHighDpiScaleFactorRoundingPolicy( Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); diff --git a/src/app/utilsadapter.cpp b/src/app/utilsadapter.cpp index 97f07074..d65b78b9 100644 --- a/src/app/utilsadapter.cpp +++ b/src/app/utilsadapter.cpp @@ -20,7 +20,6 @@ #include "lrcinstance.h" #include "systemtray.h" #include "utils.h" -#include "version.h" #include "version_info.h" #include "global.h" #include @@ -128,7 +127,7 @@ UtilsAdapter::getProjectCredits() const QString UtilsAdapter::getBuildIDStr() { - return QString(VERSION_STRING); + return BUILD_VERSION_STRING; } const QString diff --git a/src/app/version.h b/src/app/version.h deleted file mode 100644 index aea611a4..00000000 --- a/src/app/version.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -// clang-format off -#define BUILD_YEAR_CH0 (__DATE__[ 7]) -#define BUILD_YEAR_CH1 (__DATE__[ 8]) -#define BUILD_YEAR_CH2 (__DATE__[ 9]) -#define BUILD_YEAR_CH3 (__DATE__[10]) - -#define BUILD_MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') -#define BUILD_MONTH_IS_FEB (__DATE__[0] == 'F') -#define BUILD_MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') -#define BUILD_MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p') -#define BUILD_MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') -#define BUILD_MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') -#define BUILD_MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') -#define BUILD_MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u') -#define BUILD_MONTH_IS_SEP (__DATE__[0] == 'S') -#define BUILD_MONTH_IS_OCT (__DATE__[0] == 'O') -#define BUILD_MONTH_IS_NOV (__DATE__[0] == 'N') -#define BUILD_MONTH_IS_DEC (__DATE__[0] == 'D') - -#define BUILD_MONTH_CH0 \ - ((BUILD_MONTH_IS_OCT || BUILD_MONTH_IS_NOV || BUILD_MONTH_IS_DEC) ? '1' : '0') - -#define BUILD_MONTH_CH1 \ - ( \ - (BUILD_MONTH_IS_JAN) ? '1' : \ - (BUILD_MONTH_IS_FEB) ? '2' : \ - (BUILD_MONTH_IS_MAR) ? '3' : \ - (BUILD_MONTH_IS_APR) ? '4' : \ - (BUILD_MONTH_IS_MAY) ? '5' : \ - (BUILD_MONTH_IS_JUN) ? '6' : \ - (BUILD_MONTH_IS_JUL) ? '7' : \ - (BUILD_MONTH_IS_AUG) ? '8' : \ - (BUILD_MONTH_IS_SEP) ? '9' : \ - (BUILD_MONTH_IS_OCT) ? '0' : \ - (BUILD_MONTH_IS_NOV) ? '1' : \ - (BUILD_MONTH_IS_DEC) ? '2' : \ - /* error default */ '?' \ - ) - -#define BUILD_DAY_CH0 ((__DATE__[4] >= '0') ? (__DATE__[4]) : '0') -#define BUILD_DAY_CH1 (__DATE__[ 5]) - -#define BUILD_HOUR_CH0 (__TIME__[0]) -#define BUILD_HOUR_CH1 (__TIME__[1]) - -#define BUILD_MIN_CH0 (__TIME__[ 3]) -#define BUILD_MIN_CH1 (__TIME__[ 4]) - -const char VERSION_STRING[] = { - BUILD_YEAR_CH0, BUILD_YEAR_CH1, BUILD_YEAR_CH2, BUILD_YEAR_CH3, - BUILD_MONTH_CH0, BUILD_MONTH_CH1, - BUILD_DAY_CH0, BUILD_DAY_CH1, - BUILD_HOUR_CH0, BUILD_HOUR_CH1, - BUILD_MIN_CH0, BUILD_MIN_CH1, - '\0' -}; -// clang-format on diff --git a/src/version_info/version_info.cpp.in b/src/version_info/version_info.cpp.in index 3d452e27..a6356e6f 100644 --- a/src/version_info/version_info.cpp.in +++ b/src/version_info/version_info.cpp.in @@ -1,4 +1,5 @@ #include "version_info.h" const QString APP_VERSION_STRING = "@APP_VERSION_STRING@"; -const QString CORE_VERSION_STRING = "@CORE_VERSION_STRING@"; \ No newline at end of file +const QString CORE_VERSION_STRING = "@CORE_VERSION_STRING@"; +const QString BUILD_VERSION_STRING = "@BUILD_VERSION_STRING@"; \ No newline at end of file diff --git a/src/version_info/version_info.h b/src/version_info/version_info.h index 434eda5b..1654d126 100644 --- a/src/version_info/version_info.h +++ b/src/version_info/version_info.h @@ -4,3 +4,4 @@ extern const QString APP_VERSION_STRING; extern const QString CORE_VERSION_STRING; +extern const QString BUILD_VERSION_STRING;