Display Commit ID Used for Build in AboutDialog (#6516)

* Display commit ID used for build in AboutDialog

* Dynamically check for snapshots

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
ElectricalBoy 2025-01-03 01:38:25 +09:00 committed by GitHub
parent 02438e25bc
commit 091ab68811
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 0 deletions

View file

@ -22,6 +22,28 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
endif() endif()
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
# Check if Orca is on a tag
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_TAG_CHECK
)
if(NOT GIT_TAG_CHECK EQUAL 0)
add_definitions("-DSNAPSHOT_BUILD=1")
endif()
# Check current Git commit hash
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
endif()
if(DEFINED ENV{SLIC3R_STATIC}) if(DEFINED ENV{SLIC3R_STATIC})
set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC}) set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC})
else() else()

View file

@ -5,6 +5,9 @@
#define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@" #define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@"
#define SLIC3R_VERSION "@SLIC3R_VERSION@" #define SLIC3R_VERSION "@SLIC3R_VERSION@"
#define SoftFever_VERSION "@SoftFever_VERSION@" #define SoftFever_VERSION "@SoftFever_VERSION@"
#ifndef GIT_COMMIT_HASH
#define GIT_COMMIT_HASH "0000000" // 0000000 means uninitialized
#endif
#define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@" #define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@"
#define SLIC3R_BUILD_TIME "@SLIC3R_BUILD_TIME@" #define SLIC3R_BUILD_TIME "@SLIC3R_BUILD_TIME@"
//#define SLIC3R_RC_VERSION "@SLIC3R_VERSION@" //#define SLIC3R_RC_VERSION "@SLIC3R_VERSION@"

View file

@ -259,8 +259,19 @@ AboutDialog::AboutDialog()
version->SetBackgroundColour(wxColour("#4d4d4d")); version->SetBackgroundColour(wxColour("#4d4d4d"));
bs_version->SetBackgroundColour(wxColour("#4d4d4d")); bs_version->SetBackgroundColour(wxColour("#4d4d4d"));
#ifdef SNAPSHOT_BUILD
auto build_string = _L("build") + " " + std::string(GIT_COMMIT_HASH);
wxStaticText* version_build = new wxStaticText(this, wxID_ANY, build_string.c_str(), wxDefaultPosition, wxDefaultSize);
version_build->SetFont(Label::Body_12);
version_build->SetForegroundColour(wxColour("#FFFFFD"));
version_build->SetBackgroundColour(wxColour("#4d4d4d"));
#endif
vesizer->Add(version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5)); vesizer->Add(version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
#ifdef SNAPSHOT_BUILD
vesizer->Add(version_build, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
#endif
vesizer->Add(bs_version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5)); vesizer->Add(bs_version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
// #if BBL_INTERNAL_TESTING // #if BBL_INTERNAL_TESTING
// wxString build_time = wxString::Format("Build Time: %s", std::string(SLIC3R_BUILD_TIME)); // wxString build_time = wxString::Format("Build Time: %s", std::string(SLIC3R_BUILD_TIME));