From f9cdcfa6b64e3ac4cc968813f4dd39b92f68cdc6 Mon Sep 17 00:00:00 2001 From: SarahW Date: Fri, 28 May 2021 21:33:22 +0100 Subject: [PATCH] Add preprocessor variable to override version number on title bar. Modify github workflow to set version number to current git SHA, and append to artifact name. --- .github/workflows/c-cpp.yml | 12 ++++++------ src/ibm.h | 9 +++++++++ src/pc.c | 2 +- src/wx-sdl2-display-win.c | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index fef134e..80c06f5 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,9 +14,9 @@ jobs: include: - name: Ubuntu 64bit (gcc) os: ubuntu-latest - args: --enable-networking --enable-release-build + args: --enable-networking --enable-release-build CFLAGS="-DPCEM_BUILD_VERSION=${GITHUB_SHA::8}" artifacts_name: PCem-Ubuntu-${{ github.head_ref }}-${{ github.run_number }} - artifacts_path: PCem.tar.bz2 + artifacts_path: PCem-${{ github.sha }}.tar.bz2 installdeps: >- libsdl2-dev libopenal-dev @@ -25,9 +25,9 @@ jobs: - name: Windows 32bits (MSYS2) os: windows-latest compiler: MINGW32 - args: --enable-networking --enable-release-build + args: --enable-networking --enable-release-build CFLAGS="-DPCEM_BUILD_VERSION=${GITHUB_SHA::8}" artifacts_name: PCem-Windows-MINGW32-${{ github.head_ref }}-${{ github.run_number }} - artifacts_path: PCem.zip + artifacts_path: PCem-${{ github.sha }}.zip installdeps: >- base-devel zip @@ -40,9 +40,9 @@ jobs: - name: Windows 64bits (MSYS2) os: windows-latest compiler: MINGW64 - args: --enable-networking --enable-release-build + args: --enable-networking --enable-release-build CFLAGS="-DPCEM_BUILD_VERSION=${GITHUB_SHA::8}" artifacts_name: PCem-Windows-MINGW64-${{ github.head_ref }}-${{ github.run_number }} - artifacts_path: PCem.zip + artifacts_path: PCem-${{ github.sha }}.zip installdeps: >- base-devel zip diff --git a/src/ibm.h b/src/ibm.h index 75d476b..c1b6581 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -4,6 +4,15 @@ #include "timer.h" + +#ifdef PCEM_BUILD_VERSION +#define STRINGISE2(string) #string +#define STRINGISE(string) STRINGISE2(string) +#define PCEM_VERSION_STRING "build " STRINGISE(PCEM_BUILD_VERSION) +#else +#define PCEM_VERSION_STRING "v17" +#endif + #ifdef ABS #undef ABS #endif diff --git a/src/pc.c b/src/pc.c index 7b1b4c0..8e59278 100644 --- a/src/pc.c +++ b/src/pc.c @@ -605,7 +605,7 @@ void runpc() if (win_title_update) { win_title_update=0; - sprintf(s, "PCem v17 - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? "Press CTRL-END to release mouse" : "Press CTRL-END or middle button to release mouse")); + sprintf(s, "PCem " PCEM_VERSION_STRING " - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? "Press CTRL-END to release mouse" : "Press CTRL-END or middle button to release mouse")); #ifdef __APPLE__ // Needed due to modifying the UI on the non-main thread is a big no-no. dispatch_async_f(dispatch_get_main_queue(), strdup(s), _set_window_title); diff --git a/src/wx-sdl2-display-win.c b/src/wx-sdl2-display-win.c index ba2bdb6..461ba16 100644 --- a/src/wx-sdl2-display-win.c +++ b/src/wx-sdl2-display-win.c @@ -595,7 +595,7 @@ int window_create() hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ - "PCem v17", /* Title Text */ + "PCem " PCEM_VERSION_STRING, /* Title Text */ WS_OVERLAPPEDWINDOW&~WS_SIZEBOX, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */