From d7c66ac575e93c0a04956920696664c5a2c71034 Mon Sep 17 00:00:00 2001 From: sentientstardust Date: Tue, 12 May 2026 03:00:59 +0100 Subject: [PATCH] Move version number to separate file so CMake doesn't reconfigure when it changes --- .github/workflows/build_all.yml | 2 +- .github/workflows/build_orca.yml | 7 ++---- cmake/GenerateSoftFeverVersion.cmake | 25 +++++++++++++++++++ scripts/build_flatpak_with_docker.sh | 6 ++--- scripts/flatpak/com.orcaslicer.OrcaSlicer.yml | 2 ++ src/dev-utils/BaseException.cpp | 10 +++++--- src/libslic3r/CMakeLists.txt | 11 ++++++++ src/libslic3r/libslic3r_version.h.in | 3 ++- src/libslic3r/utils.cpp | 4 +-- src/slic3r/Utils/Http.cpp | 3 ++- version.inc | 4 ++- version_number.txt | 1 + 12 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 cmake/GenerateSoftFeverVersion.cmake create mode 100644 version_number.txt diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index adbc72abb2..1b08d93060 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -142,7 +142,7 @@ jobs: - uses: actions/checkout@v6 - name: Get the version and date run: | - ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2) + ver_pure=$(cat version_number.txt) if [[ "${{ github.event_name }}" == "pull_request" ]]; then ver="PR-${{ github.event.number }}" git_commit_hash="${{ github.event.pull_request.head.sha }}" diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index d84fa5d687..46d7a6cba5 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -53,7 +53,7 @@ jobs: - name: Get the version and date on Ubuntu and macOS if: runner.os != 'Windows' run: | - ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2) + ver_pure=$(cat version_number.txt) if [[ "${{ github.event_name }}" == "pull_request" ]]; then ver="PR-${{ github.event.number }}" git_commit_hash="${{ github.event.pull_request.head.sha }}" @@ -79,10 +79,7 @@ jobs: $ver = "PR" + $prNumber $git_commit_hash = "${{ github.event.pull_request.head.sha }}" } else { - $versionContent = Get-Content version.inc -Raw - if ($versionContent -match 'set\(SoftFever_VERSION "(.*?)"\)') { - $ver = $matches[1] - } + $ver = (Get-Content version_number.txt -First 1).Trim() $ver = "V$ver" $git_commit_hash = "" } diff --git a/cmake/GenerateSoftFeverVersion.cmake b/cmake/GenerateSoftFeverVersion.cmake new file mode 100644 index 0000000000..cfe8ca0bb5 --- /dev/null +++ b/cmake/GenerateSoftFeverVersion.cmake @@ -0,0 +1,25 @@ +if(NOT DEFINED INPUT) + message(FATAL_ERROR "INPUT is required") +endif() + +if(NOT DEFINED OUTPUT) + message(FATAL_ERROR "OUTPUT is required") +endif() + +file(STRINGS "${INPUT}" SOFTFEVER_VERSION LIMIT_COUNT 1) +string(STRIP "${SOFTFEVER_VERSION}" SOFTFEVER_VERSION) + +set(CONTENT [=[ +#include "libslic3r_version.h" + +namespace Slic3r { + +const char* softfever_version() +{ + return "@SOFTFEVER_VERSION@"; +} + +} // namespace Slic3r +]=]) +string(CONFIGURE "${CONTENT}" CONTENT @ONLY) +file(WRITE "${OUTPUT}" "${CONTENT}") diff --git a/scripts/build_flatpak_with_docker.sh b/scripts/build_flatpak_with_docker.sh index 898ec2c56a..da40709299 100755 --- a/scripts/build_flatpak_with_docker.sh +++ b/scripts/build_flatpak_with_docker.sh @@ -77,9 +77,9 @@ esac # ---------- version & commit ---------- cd "$PROJECT_ROOT" -VER_PURE=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2) +VER_PURE=$(cat version_number.txt) if [ -z "$VER_PURE" ]; then - echo "Error: could not extract version from version.inc" >&2 + echo "Error: could not extract version from version_number.txt" >&2 exit 1 fi VER="V${VER_PURE}" @@ -228,4 +228,4 @@ echo "Install with:" echo " flatpak install --user ${BUNDLE_NAME}" elapsed=$SECONDS -printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) \ No newline at end of file +printf "\nBuild completed in %dh %dm %ds\n" $((elapsed/3600)) $((elapsed%3600/60)) $((elapsed%60)) diff --git a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml index c527938364..2c2405099b 100644 --- a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml +++ b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml @@ -365,6 +365,8 @@ modules: path: ../../LICENSE.txt - type: file path: ../../version.inc + - type: file + path: ../../version_number.txt - type: file path: ../run_gettext.sh dest: scripts diff --git a/src/dev-utils/BaseException.cpp b/src/dev-utils/BaseException.cpp index d3f36fcc63..9fd461af7b 100644 --- a/src/dev-utils/BaseException.cpp +++ b/src/dev-utils/BaseException.cpp @@ -38,8 +38,12 @@ CBaseException::CBaseException(HANDLE hProcess, WORD wPID, LPCTSTR lpSymbolPath, std::string log_filename = crash_log_path.string(); output_file->open(log_filename, std::ios::out | std::ios::app); - // Output app build info in crash log so we could look for the correct PDB files - OutputString(_T("%s\n\n"), _T(SLIC3R_APP_NAME " " SoftFever_VERSION " Build " GIT_COMMIT_HASH)); + const std::string build_info = std::string(SLIC3R_APP_NAME) + " " + SoftFever_VERSION + " Build " + GIT_COMMIT_HASH; +#ifdef UNICODE + OutputString(_T("%S\n\n"), build_info.c_str()); +#else + OutputString(_T("%s\n\n"), build_info.c_str()); +#endif } } @@ -390,4 +394,4 @@ void CBaseException::ShowExceptionInformation() ShowRegistorInformation(m_pEp->ContextRecord); ShowCallstack(GetCurrentThread(), m_pEp->ContextRecord); -} \ No newline at end of file +} diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index be216c2229..ae9f292ccd 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -8,6 +8,16 @@ if(NOT DEFINED ORCA_CHECK_GCODE_PLACEHOLDERS) endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libslic3r_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h @ONLY) +set(LIBSLIC3R_VERSION_CPP "${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.cpp") +add_custom_command( + OUTPUT "${LIBSLIC3R_VERSION_CPP}" + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${SOFTFEVER_VERSION_FILE}" + "-DOUTPUT=${LIBSLIC3R_VERSION_CPP}" + -P "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake" + DEPENDS "${SOFTFEVER_VERSION_FILE}" "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake" + VERBATIM +) if (MINGW) add_compile_options(-Wa,-mbig-obj) @@ -539,6 +549,7 @@ if (MSVC AND "${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") # 32 bit MSVC workaround endif () encoding_check(libslic3r) +target_sources(libslic3r PRIVATE "${LIBSLIC3R_VERSION_CPP}") target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0) target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/libslic3r/libslic3r_version.h.in b/src/libslic3r/libslic3r_version.h.in index 750e092d28..0b7bc1c07e 100644 --- a/src/libslic3r/libslic3r_version.h.in +++ b/src/libslic3r/libslic3r_version.h.in @@ -4,7 +4,8 @@ #define SLIC3R_APP_NAME "@SLIC3R_APP_NAME@" #define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@" #define SLIC3R_VERSION "@SLIC3R_VERSION@" -#define SoftFever_VERSION "@SoftFever_VERSION@" +namespace Slic3r { const char* softfever_version(); } +#define SoftFever_VERSION (Slic3r::softfever_version()) #ifndef GIT_COMMIT_HASH #define GIT_COMMIT_HASH "0000000" // 0000000 means uninitialized #endif diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 25aad9a066..8656d18c47 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -1208,12 +1208,12 @@ std::string string_printf(const char *format, ...) std::string header_slic3r_generated() { - return std::string(SLIC3R_APP_NAME " " SoftFever_VERSION); + return std::string(SLIC3R_APP_NAME) + " " + SoftFever_VERSION; } std::string header_gcodeviewer_generated() { - return std::string(GCODEVIEWER_APP_NAME " " SoftFever_VERSION); + return std::string(GCODEVIEWER_APP_NAME) + " " + SoftFever_VERSION; } unsigned get_current_pid() diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index 6c4d90035e..8e898ab0cd 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -189,7 +189,8 @@ Http::priv::priv(const std::string &url) set_timeout_max(DEFAULT_TIMEOUT_MAX); ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, log_trace); ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); // curl makes a copy internally - ::curl_easy_setopt(curl, CURLOPT_USERAGENT, SLIC3R_APP_NAME "/" SoftFever_VERSION); + const std::string user_agent = std::string(SLIC3R_APP_NAME) + "/" + SoftFever_VERSION; + ::curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent.c_str()); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer.front()); #ifdef __WINDOWS__ ::curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_MAX_TLSv1_2); diff --git a/version.inc b/version.inc index bf4d2d3819..d8f907aaa4 100644 --- a/version.inc +++ b/version.inc @@ -7,7 +7,9 @@ set(SLIC3R_APP_KEY "OrcaSlicer") if(NOT DEFINED BBL_INTERNAL_TESTING) set(BBL_INTERNAL_TESTING "0") endif() -set(SoftFever_VERSION "1.0.5") +set(SOFTFEVER_VERSION_FILE "${CMAKE_CURRENT_LIST_DIR}/version_number.txt") +file(STRINGS "${SOFTFEVER_VERSION_FILE}" SoftFever_VERSION LIMIT_COUNT 1) +string(STRIP "${SoftFever_VERSION}" SoftFever_VERSION) string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" SoftFever_VERSION_MATCH ${SoftFever_VERSION}) set(ORCA_VERSION_MAJOR ${CMAKE_MATCH_1}) diff --git a/version_number.txt b/version_number.txt new file mode 100644 index 0000000000..66c4c2263e --- /dev/null +++ b/version_number.txt @@ -0,0 +1 @@ +1.0.9