diff --git a/.appveyor.yml b/.appveyor.yml index 2b84678..4e3a0af 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,6 +28,7 @@ init: - set TAG_NAME=%APPVEYOR_REPO_TAG_NAME% build_script: + - python ./build_scripts/append_to_version_file.py %APPVEYOR_REPO_COMMIT:~0,8% - python ./build_scripts/run-clang-format.py ./src -r --clang-format-executable "C:\Program Files\LLVM\bin\clang-format.exe" --color always - call "build_windows.cmd" diff --git a/.gitignore b/.gitignore index a8a664c..83a7908 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ debug release assets bin +build Makefile* *.vcxproj* *.log @@ -12,4 +13,5 @@ Makefile* installer/*.exe *.user* build_scripts/win/__pycache__ -build_scripts/win/current_build.bat \ No newline at end of file +build_scripts/win/current_build.bat +AdvancedSettings_resource.rc diff --git a/advancedSettings.pro b/advancedSettings.pro index 4396480..2b13e11 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -3,6 +3,17 @@ 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\\\" +# Qmake can't handle non-integers in the version string, +# so we take out anything after the dash. +SPLIT_VERSION_STRING = $$split(VERSION, -) +NUMERICAL_VERSION_NUMBER = $$member(SPLIT_VERSION_STRING, 0, 0) +VERSION = $$NUMERICAL_VERSION_NUMBER + +# Keep the literal version number in the description field for debugging. +QMAKE_TARGET_DESCRIPTION = "$$cat($$PWD/build_scripts/compile_version_string.txt)" + 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 new file mode 100644 index 0000000..33d2906 --- /dev/null +++ b/build_scripts/append_to_version_file.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +from sys import argv +from os import path, remove + +current_path = path.dirname(path.realpath(__file__)) +version_file_path = path.join(current_path, "compile_version_string.txt") + +def get_version_string(): + with open(version_file_path, "r") as file: + contents = file.readline() + return contents.strip('"') + +def set_version_string(new_version_string): + remove(version_file_path) + with open(version_file_path, "w") as file: + file.write(new_version_string) + +def main(): + current_version = get_version_string() + if "-release" in current_version.lower(): + current_version.replace("-release", "") + else: + new_version = current_version + "+" + argv[1] + + set_version_string(new_version) + +if __name__ == "__main__": + main() diff --git a/build_scripts/compile_version_string.txt b/build_scripts/compile_version_string.txt new file mode 100644 index 0000000..fee2d3e --- /dev/null +++ b/build_scripts/compile_version_string.txt @@ -0,0 +1 @@ +3.1.0-dev \ No newline at end of file diff --git a/build_scripts/qt/resources.pri b/build_scripts/qt/resources.pri index f0c32c9..7cf19f4 100644 --- a/build_scripts/qt/resources.pri +++ b/build_scripts/qt/resources.pri @@ -47,4 +47,4 @@ DISTFILES += \ src/res/qml/desktop_overlay_page/translation_back_forwards/SteamDesktopTranslationBackForwards.qml \ src/res/qml/desktop_overlay_page/translation_up_down/SteamDesktopTranslationUpDown.qml \ -RC_FILE = src/res/icon.rc +win32:RC_ICONS += src/res/img/icons/advicon256px.ico diff --git a/build_scripts/win/build.py b/build_scripts/win/build.py index a1d8a21..2a15d55 100644 --- a/build_scripts/win/build.py +++ b/build_scripts/win/build.py @@ -154,6 +154,8 @@ def build(): COMPILE_MODE = "" COMPILER = "" + say("Attempting to build version: " + VERSION_STRING) + say("Testing if all required build environment variables are set:") QT_LOC = get_required_env_var_path(QT_LOC_VAR_NAME, QT_LOC_DEFAULT) VS_LOC = get_required_env_var_path(VS_LOC_VAR_NAME, VS_LOC_DEFAULT) diff --git a/build_scripts/win/common.py b/build_scripts/win/common.py index 3457895..2057909 100644 --- a/build_scripts/win/common.py +++ b/build_scripts/win/common.py @@ -8,10 +8,15 @@ import subprocess import shutil import distutils.dir_util +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 + + #Const globals -#Version string must be bumped every release. -#TODO: See developer documentation. -VERSION_STRING = "3-1-0-dev" +VERSION_STRING = get_version_string() EXIT_CODE_SUCCESS = 0 EXIT_CODE_FAILURE_BUILD_APP = 1 @@ -62,17 +67,17 @@ def say(message: str): """ global current_activity print(current_activity + ": " + message) - + def say_error(message: str): """ Prints an error message to the console. - - Not currently different from say, but put in incase somebody wanted to + + Not currently different from say, but put in incase somebody wanted to do something fancy with outputting to stderr or something instead. """ global current_activity - print(current_activity + ": " + message) - + print(current_activity + ": " + message) + def is_env_var_set(env_var_name: str): """ Returns whether or not an environment variable is set. @@ -81,7 +86,7 @@ def is_env_var_set(env_var_name: str): if var is None: return False return True - + def add_line_to_run_bat_file(line: str): """ Adds a line ended by a newline to the batch file. @@ -92,7 +97,7 @@ def add_line_to_run_bat_file(line: str): def add_error_handling_line_to_bat_file(): """ Adds an error handling line to the batch file. - + This is because some applications don't cause the script to error out even if they exit with an error. """ @@ -117,23 +122,23 @@ def get_required_env_var_path(env_var_name: str, default_env_var_value: str): exit_on_error(EXIT_CODE_FAILURE_BUILD_LOCATION) say(f"{env_var_name} exists.") return path - + def create_batch_file(): """ Creates a batch file in the dir. Must be called by another outside batch file. """ file = open(get_project_dir() + "\\build_scripts\\win\\current_build.bat", "w+") file.write(bat_file_contents) - file.close() + file.close() def exit_on_error(error_number): """Wrapper around sys.exit.""" sys.exit(error_number) - + def set_dirs(): """ Sets up the directories. - + We know that the project dir will always be two dirs up from the dir the file is in. """ global ORIGINAL_DIR @@ -142,50 +147,50 @@ def set_dirs(): ORIGINAL_DIR = os.path.dirname(__file__) PROJECT_DIR = os.path.abspath(os.path.join(ORIGINAL_DIR, r"..\..")) DEPLOY_DIR = DEPLOY_DIR = PROJECT_DIR + OUTPUT_DIR - + print(ORIGINAL_DIR) - + def get_project_dir(): return PROJECT_DIR - + def get_original_dir(): - return ORIGINAL_DIR - + return ORIGINAL_DIR + def get_deploy_dir(): return DEPLOY_DIR - + def copy_file(src, dest): """Copies a file and outputs status to console.""" say(f"Copying {src} to {dest}") shutil.copy(src, dest) - say(f"{src} to {dest} copied.") - + say(f"{src} to {dest} copied.") + def copy_folder(src, dest): """Copies a folder and outputs status to console.""" say(f"Copying {src} to {dest}") - distutils.dir_util.copy_tree(src, dest) - say(f"{src} to {dest} copied.") - - - - - - - - - - - - - - - - - - - - - - - - + distutils.dir_util.copy_tree(src, dest) + say(f"{src} to {dest} copied.") + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/developer_docs.md b/docs/developer_docs.md index c7e2f02..af725ce 100644 --- a/docs/developer_docs.md +++ b/docs/developer_docs.md @@ -1,23 +1,17 @@ - # OpenVR Advanced Settings Developer Docs For things that don't directly belong a single place in the source code. - > * [New Patch Release Checklist](#patch_checklist) - > * [Increment Version Numbers](#inc_vers_numbers) +# New Patch Release Checklist - -## New Patch Release Checklist +## Increment Version Numbers - -### Increment Version Numbers +The version number string is kept in the `./build_scripts/compile_version_string.txt` file. The file is read by at compile time by whatever needs the current version number. Currently it is being used in 3 locations. -Currently there are three version strings in the source. - -1. `src\overlaycontroller.h` - Variable named `applicationVersionString`. +1. `advancedSettings.pro` - `VERSION` variable and `APPLICATION_VERSION` define. 2. `build_scripts\win\common.py` - Variable named `VERSION_STRING`. 3. `installer\installer.nsi` - Variable named `VERSION_STRING`. -The first string should be three digits separated by dots (periods), as described in [semantic versioning](https://semver.org/) (like "2.8.0"). The second and third should be three digits separated by hyphens/dashes (like "2-8-0"). +The string should be three digits separated by dots (periods), as described in [semantic versioning](https://semver.org/) (like "2.8.0"). Additional qualifiers may be appended with a dash (and only a dash). The `QMAKE` build script relies on there only being dot separated integers before the first dash. If there are non-integers (or letters) before the first dash the Windows build will fail. -The reason for the difference is that the first string is only used as a string in the source code, while the second and third are used to name files. Some operating system can become confused with more than one dot in the file name (like Windows). It's better to just avoid the situation entirely. \ No newline at end of file +The AppVeyor build server will append the last 8 digits of the commit hash. This is in order to make debugging various versions easier. If `-release` is found in the original version string, `-release` will be removed and a hash will not be appended. diff --git a/installer/installer.nsi b/installer/installer.nsi index c7e0264..69d5fd9 100644 --- a/installer/installer.nsi +++ b/installer/installer.nsi @@ -11,7 +11,7 @@ !define THIRDDIR "..\third-party" !define PACKAGEDIR "..\src\package_files" !define PROJECTDIR "..\" - !define VERSION_STRING "3-1-0-dev" + !define /file VERSION_STRING "..\build_scripts\compile_version_string.txt" ;Installer icon diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index d515fb8..a33119b 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -48,7 +48,9 @@ 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 = "v3.1.0-dev"; + +constexpr const char* applicationVersionString = APPLICATION_VERSION; + } // namespace application_strings // application namespace diff --git a/src/res/icon.rc b/src/res/icon.rc deleted file mode 100644 index c1f36c5..0000000 --- a/src/res/icon.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "img/icons/advicon256px.ico" \ No newline at end of file