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.
This commit is contained in:
Vasily
2019-04-19 22:30:04 +02:00
parent 9bebfe3067
commit 164158330e
6 changed files with 9 additions and 8 deletions
+3
View File
@@ -3,6 +3,9 @@ CONFIG += c++1z
DEFINES += ELPP_THREAD_SAFE ELPP_QT_LOGGING ELPP_NO_DEFAULT_LOG_FILE 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_MAJOR_VERSION, 5): error("requires Qt 5.12 or higher")
lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 or higher") lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 or higher")
+1 -1
View File
@@ -13,7 +13,7 @@ def get_version_string():
def set_version_string(new_version_string): def set_version_string(new_version_string):
remove(version_file_path) remove(version_file_path)
with open(version_file_path, "w") as file: with open(version_file_path, "w") as file:
file.write("\"" + new_version_string + "\"") file.write(new_version_string)
def main(): def main():
current_version = get_version_string() current_version = get_version_string()
+1 -1
View File
@@ -1 +1 @@
"3.1.0-dev-new" 3.1.0-dev-new
+1 -1
View File
@@ -12,7 +12,7 @@ def get_version_string():
dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = os.path.dirname(os.path.realpath(__file__))
with open(dir_path + "/../compile_version_string.txt", "r") as file: with open(dir_path + "/../compile_version_string.txt", "r") as file:
contents = file.readline() contents = file.readline()
return contents.strip('"') return contents
#Const globals #Const globals
+1 -2
View File
@@ -11,8 +11,7 @@
!define THIRDDIR "..\third-party" !define THIRDDIR "..\third-party"
!define PACKAGEDIR "..\src\package_files" !define PACKAGEDIR "..\src\package_files"
!define PROJECTDIR "..\" !define PROJECTDIR "..\"
!define /file VERSION_STRING_QUOTES "..\build_scripts\compile_version_string.txt" !define /file VERSION_STRING "..\build_scripts\compile_version_string.txt"
!searchreplace VERSION_STRING ${VERSION_STRING_QUOTES} "$\"" ""
;Installer icon ;Installer icon
+2 -3
View File
@@ -48,9 +48,8 @@ constexpr auto applicationOrganizationName = "AdvancedSettings-Team";
constexpr auto applicationName = "OpenVRAdvancedSettings"; constexpr auto applicationName = "OpenVRAdvancedSettings";
constexpr const char* applicationKey = "OVRAS-Team.AdvancedSettings"; constexpr const char* applicationKey = "OVRAS-Team.AdvancedSettings";
constexpr const char* applicationDisplayName = "Advanced Settings"; 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 } // namespace application_strings