From 164158330ee2631a86e42f4a425873472f5d2333 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 19 Apr 2019 19:35:35 +0200 Subject: [PATCH] Convert C++ version string to be define instead of include This allows Qmake to use the version number as well as not requiring all other uses of the version string to strip double quotes from it. This also reduces the fragility of the version string as it was required to be a valid C++ char*, even in contexts where that wouldn't matter. --- advancedSettings.pro | 3 +++ build_scripts/append_to_version_file.py | 2 +- build_scripts/compile_version_string.txt | 2 +- build_scripts/win/common.py | 2 +- installer/installer.nsi | 3 +-- src/overlaycontroller.h | 5 ++--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/advancedSettings.pro b/advancedSettings.pro index 4396480..2d4e754 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -3,6 +3,9 @@ CONFIG += c++1z DEFINES += ELPP_THREAD_SAFE ELPP_QT_LOGGING ELPP_NO_DEFAULT_LOG_FILE +VERSION = "$$cat($$PWD/build_scripts/compile_version_string.txt)" +DEFINES += APPLICATION_VERSION=\\\"$$VERSION\\\" + lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5.12 or higher") lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 or higher") diff --git a/build_scripts/append_to_version_file.py b/build_scripts/append_to_version_file.py index 99d33ef..33d2906 100644 --- a/build_scripts/append_to_version_file.py +++ b/build_scripts/append_to_version_file.py @@ -13,7 +13,7 @@ def get_version_string(): def set_version_string(new_version_string): remove(version_file_path) with open(version_file_path, "w") as file: - file.write("\"" + new_version_string + "\"") + file.write(new_version_string) def main(): current_version = get_version_string() diff --git a/build_scripts/compile_version_string.txt b/build_scripts/compile_version_string.txt index 7107992..3b0338f 100644 --- a/build_scripts/compile_version_string.txt +++ b/build_scripts/compile_version_string.txt @@ -1 +1 @@ -"3.1.0-dev-new" \ No newline at end of file +3.1.0-dev-new \ No newline at end of file diff --git a/build_scripts/win/common.py b/build_scripts/win/common.py index 7b3ae9a..2057909 100644 --- a/build_scripts/win/common.py +++ b/build_scripts/win/common.py @@ -12,7 +12,7 @@ def get_version_string(): dir_path = os.path.dirname(os.path.realpath(__file__)) with open(dir_path + "/../compile_version_string.txt", "r") as file: contents = file.readline() - return contents.strip('"') + return contents #Const globals diff --git a/installer/installer.nsi b/installer/installer.nsi index 7303aea..69d5fd9 100644 --- a/installer/installer.nsi +++ b/installer/installer.nsi @@ -11,8 +11,7 @@ !define THIRDDIR "..\third-party" !define PACKAGEDIR "..\src\package_files" !define PROJECTDIR "..\" - !define /file VERSION_STRING_QUOTES "..\build_scripts\compile_version_string.txt" - !searchreplace VERSION_STRING ${VERSION_STRING_QUOTES} "$\"" "" + !define /file VERSION_STRING "..\build_scripts\compile_version_string.txt" ;Installer icon diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 24b2fa7..a33119b 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -48,9 +48,8 @@ constexpr auto applicationOrganizationName = "AdvancedSettings-Team"; constexpr auto applicationName = "OpenVRAdvancedSettings"; constexpr const char* applicationKey = "OVRAS-Team.AdvancedSettings"; constexpr const char* applicationDisplayName = "Advanced Settings"; -constexpr const char* applicationVersionString = { -#include "../build_scripts/compile_version_string.txt" -}; + +constexpr const char* applicationVersionString = APPLICATION_VERSION; } // namespace application_strings