Stop commit hash being a global compiler definition to reduce build time
This commit is contained in:
@ -85,6 +85,7 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
set(GIT_COMMIT_HASH "0000000")
|
||||||
if(DEFINED ENV{git_commit_hash} AND NOT "$ENV{git_commit_hash}" STREQUAL "")
|
if(DEFINED ENV{git_commit_hash} AND NOT "$ENV{git_commit_hash}" STREQUAL "")
|
||||||
message(STATUS "Specified git commit hash: $ENV{git_commit_hash}")
|
message(STATUS "Specified git commit hash: $ENV{git_commit_hash}")
|
||||||
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
@ -99,7 +100,6 @@ if(DEFINED ENV{git_commit_hash} AND NOT "$ENV{git_commit_hash}" STREQUAL "")
|
|||||||
# No .git directory (e.g., Flatpak sandbox) — truncate directly
|
# No .git directory (e.g., Flatpak sandbox) — truncate directly
|
||||||
string(SUBSTRING "$ENV{git_commit_hash}" 0 7 GIT_COMMIT_HASH)
|
string(SUBSTRING "$ENV{git_commit_hash}" 0 7 GIT_COMMIT_HASH)
|
||||||
endif()
|
endif()
|
||||||
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
|
||||||
elseif(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
elseif(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
# Check current Git commit hash
|
# Check current Git commit hash
|
||||||
execute_process(
|
execute_process(
|
||||||
@ -108,7 +108,6 @@ elseif(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED ENV{SLIC3R_STATIC})
|
if(DEFINED ENV{SLIC3R_STATIC})
|
||||||
|
|||||||
@ -6,6 +6,10 @@ if(NOT DEFINED OUTPUT)
|
|||||||
message(FATAL_ERROR "OUTPUT is required")
|
message(FATAL_ERROR "OUTPUT is required")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED GIT_COMMIT_HASH)
|
||||||
|
set(GIT_COMMIT_HASH "0000000")
|
||||||
|
endif()
|
||||||
|
|
||||||
file(STRINGS "${INPUT}" SOFTFEVER_VERSION LIMIT_COUNT 1)
|
file(STRINGS "${INPUT}" SOFTFEVER_VERSION LIMIT_COUNT 1)
|
||||||
string(STRIP "${SOFTFEVER_VERSION}" SOFTFEVER_VERSION)
|
string(STRIP "${SOFTFEVER_VERSION}" SOFTFEVER_VERSION)
|
||||||
|
|
||||||
@ -19,6 +23,11 @@ const char* softfever_version()
|
|||||||
return "@SOFTFEVER_VERSION@";
|
return "@SOFTFEVER_VERSION@";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* git_commit_hash()
|
||||||
|
{
|
||||||
|
return "@GIT_COMMIT_HASH@";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
]=])
|
]=])
|
||||||
string(CONFIGURE "${CONTENT}" CONTENT @ONLY)
|
string(CONFIGURE "${CONTENT}" CONTENT @ONLY)
|
||||||
|
|||||||
@ -14,6 +14,7 @@ add_custom_command(
|
|||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
"-DINPUT=${SOFTFEVER_VERSION_FILE}"
|
"-DINPUT=${SOFTFEVER_VERSION_FILE}"
|
||||||
"-DOUTPUT=${LIBSLIC3R_VERSION_CPP}"
|
"-DOUTPUT=${LIBSLIC3R_VERSION_CPP}"
|
||||||
|
"-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}"
|
||||||
-P "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake"
|
-P "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake"
|
||||||
DEPENDS "${SOFTFEVER_VERSION_FILE}" "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake"
|
DEPENDS "${SOFTFEVER_VERSION_FILE}" "${CMAKE_SOURCE_DIR}/cmake/GenerateSoftFeverVersion.cmake"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
|||||||
@ -5,10 +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@"
|
||||||
namespace Slic3r { const char* softfever_version(); }
|
namespace Slic3r { const char* softfever_version(); }
|
||||||
|
namespace Slic3r { const char* git_commit_hash(); }
|
||||||
#define SoftFever_VERSION (Slic3r::softfever_version())
|
#define SoftFever_VERSION (Slic3r::softfever_version())
|
||||||
#ifndef GIT_COMMIT_HASH
|
#define GIT_COMMIT_HASH (Slic3r::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_RC_VERSION "@SLIC3R_VERSION@"
|
//#define SLIC3R_RC_VERSION "@SLIC3R_VERSION@"
|
||||||
#define BBL_INTERNAL_TESTING @BBL_INTERNAL_TESTING@
|
#define BBL_INTERNAL_TESTING @BBL_INTERNAL_TESTING@
|
||||||
|
|||||||
Reference in New Issue
Block a user