diff --git a/CMakeLists.txt b/CMakeLists.txt index 40fe0d091..78fb7da8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) 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}) set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC}) else() diff --git a/src/libslic3r/libslic3r_version.h.in b/src/libslic3r/libslic3r_version.h.in index 90383c93a..31af715bc 100644 --- a/src/libslic3r/libslic3r_version.h.in +++ b/src/libslic3r/libslic3r_version.h.in @@ -5,6 +5,9 @@ #define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@" #define SLIC3R_VERSION "@SLIC3R_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_TIME "@SLIC3R_BUILD_TIME@" //#define SLIC3R_RC_VERSION "@SLIC3R_VERSION@" diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 52d04bed5..e7ff3caa3 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -259,8 +259,19 @@ AboutDialog::AboutDialog() 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)); + #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)); // #if BBL_INTERNAL_TESTING // wxString build_time = wxString::Format("Build Time: %s", std::string(SLIC3R_BUILD_TIME));