From 8bc9695a7d34053cb242a0d859a46f99435ba0e9 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 19 Jul 2023 18:47:42 +0200 Subject: [PATCH] Log the module version on each application start --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/pr.yml | 7 +++++++ source/main.cpp | 5 +++++ source/version.h | 2 ++ 4 files changed, 21 insertions(+) create mode 100644 source/version.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0af8e78..f6ad66b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,13 @@ jobs: needs: clang-format steps: - uses: actions/checkout@v3 + - name: create version.h + run: | + git_hash=$(git rev-parse --short "$GITHUB_SHA") + cat < ./source/version.h + #pragma once + #define MODULE_VERSION_EXTRA " (nightly-$git_hash)" + EOF - name: build binary run: | docker build . -t builder diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c8b7ce9..25c6c62 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,6 +26,13 @@ jobs: needs: clang-format steps: - uses: actions/checkout@v3 + - name: create version.h + run: | + git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}") + cat < ./source/version.h + #pragma once + #define MODULE_VERSION_EXTRA " (nightly-$git_hash)" + EOF - name: build binary run: | docker build . -t builder diff --git a/source/main.cpp b/source/main.cpp index 74ed86d..c99628c 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,6 +1,7 @@ #include "exports.h" #include "logger.h" #include "sdcard.h" +#include "version.h" #include #include #include @@ -22,6 +23,9 @@ std::thread *mountThread = nullptr; bool sStopThread = false; bool sIsSDInsertedAndMounted = false; +#define MODULE_VERSION "v0.1" +#define MODULE_VERSION_FULL MODULE_VERSION MODULE_VERSION_EXTRA + int mount_thread() { std::unique_lock lk(*cv_m); // Wait until the main thread has checked the sd status once. @@ -49,6 +53,7 @@ int mount_thread() { } WUMS_APPLICATION_STARTS() { + OSReport("Running SDHotSwapModule " MODULE_VERSION_FULL "\n"); initLogging(); sStopThread = false; diff --git a/source/version.h b/source/version.h new file mode 100644 index 0000000..78433de --- /dev/null +++ b/source/version.h @@ -0,0 +1,2 @@ +#pragma once +#define MODULE_VERSION_EXTRA "" \ No newline at end of file