From 9699d63e7034b6b7d95bb4ca0a8633ca24d1367e Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 5 Nov 2021 22:02:34 -0300 Subject: [PATCH] Add icon type switch to CMake and de-duplicate wide version strings --- CMakeLists.txt | 9 +++++++++ src/86box.c | 2 +- src/include/86box/version.h.in | 28 +++++++++++++++++++++++----- src/win/win_sdl.c | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9565d55b5..89e661fcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,15 @@ CMAKE_DEPENDENT_OPTION(VNC "VNC renderer" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(XL24 "ATI VGA Wonder XL24 (ATI-28800-6)" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(VECT486VL "HP Vectra 486VL" ON "DEV_BRANCH" OFF) +string(TOLOWER "${BUILD_TYPE}" BUILD_TYPE_LOWER) +if(BUILD_TYPE_LOWER STREQUAL "release") + add_compile_definitions(RELEASE_BUILD) +elseif(BUILD_TYPE_LOWER STREQUAL "beta") + add_compile_definitions(BETA_BUILD) +elseif(BUILD_TYPE_LOWER STREQUAL "alpha") + add_compile_definitions(ALPHA_BUILD) +endif() + # HACK: Avoid a MSVC2019 compiler bug on ARM64 Debug builds if(MSVC_TOOLSET_VERSION GREATER_EQUAL 142 AND ARCH STREQUAL "arm64") # Define a cache option in case somebody wants to disable this workaround diff --git a/src/86box.c b/src/86box.c index e93f8bbe3..a9f78dc53 100644 --- a/src/86box.c +++ b/src/86box.c @@ -665,7 +665,7 @@ usage: info = localtime(&now); strftime(temp, sizeof(temp), "%Y/%m/%d %H:%M:%S", info); pclog("#\n# %ls v%ls logfile, created %s\n#\n", - EMU_NAME_W, EMU_VERSION_W, temp); + EMU_NAME_W, EMU_VERSION_FULL_W, temp); pclog("# VM: %s\n#\n", vm_name); pclog("# Emulator path: %s\n", exe_path); pclog("# Userfiles path: %s\n", usr_path); diff --git a/src/include/86box/version.h.in b/src/include/86box/version.h.in index 67832258d..ec7a4fdb7 100644 --- a/src/include/86box/version.h.in +++ b/src/include/86box/version.h.in @@ -13,19 +13,37 @@ * Copyright 2020 Miran Grca. */ +#define _LSTR(s) L ## s +#define LSTR(s) _LSTR(s) + /* Version info. */ #define EMU_NAME "@CMAKE_PROJECT_NAME@" -#define EMU_NAME_W L"@CMAKE_PROJECT_NAME@" +#define EMU_NAME_W LSTR(EMU_NAME) #define EMU_VERSION "@CMAKE_PROJECT_VERSION@" -#define EMU_VERSION_W L"@CMAKE_PROJECT_VERSION@" -#define EMU_VERSION_EX "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@0" +#define EMU_VERSION_W LSTR(EMU_VERSION) +#define EMU_VERSION_EX "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@@CMAKE_PROJECT_VERSION_PATCH@" #define EMU_VERSION_MAJ @CMAKE_PROJECT_VERSION_MAJOR@ #define EMU_VERSION_MIN @CMAKE_PROJECT_VERSION_MINOR@ -#define COPYRIGHT_YEAR "2020" +#cmakedefine EMU_BUILD "@EMU_BUILD@" +#cmakedefine EMU_GIT_HASH "@EMU_GIT_HASH@" + +#ifdef EMU_BUILD +# define EMU_BUILD_W LSTR(EMU_BUILD) +# define EMU_VERSION_FULL EMU_VERSION " [" EMU_BUILD "]" +# define EMU_VERSION_FULL_W EMU_VERSION_W L" [" EMU_BUILD_W L"]" +#else +# define EMU_VERSION_FULL EMU_VERSION +# define EMU_VERSION_FULL_W EMU_VERSION_W +#endif +#ifdef EMU_GIT_HASH +# define EMU_GIT_HASH_W LSTR(EMU_GIT_HASH) +#endif + +#define COPYRIGHT_YEAR "2021" /* Web URL info. */ -#define EMU_SITE L"@CMAKE_PROJECT_HOMEPAGE_URL@" +#define EMU_SITE L"86box.net" #define EMU_ROMS_URL L"https://github.com/86Box/roms/releases/latest" #define EMU_DOCS_URL L"https://86box.readthedocs.io" diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index e8bdd6e0d..af876540d 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -459,7 +459,7 @@ sdl_init_common(int flags) sdl_h = GetSystemMetrics(SM_CYSCREEN); /* Create the desktop-covering window. */ - _swprintf(temp, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); + _swprintf(temp, L"%s v%s", EMU_NAME_W, EMU_VERSION_FULL_W); sdl_parent_hwnd = CreateWindow(SDL_CLASS_NAME, temp, WS_POPUP, 0, 0, sdl_w, sdl_h, HWND_DESKTOP, NULL, hinstance, NULL); ShowWindow(sdl_parent_hwnd, FALSE);