mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-12 21:30:37 +01:00
nix/cmake: make it print the version hash (#683)
* cmake: allow passing commit and version commit * nix: don't set HYPRLOCK_VERSION_COMMIT (Nix) Makes it so `--version` always prints the short commit hash, instead of not printing it.
This commit is contained in:
parent
a27585b383
commit
82b63a6930
2 changed files with 31 additions and 17 deletions
|
@ -28,25 +28,39 @@ set(CMAKE_CXX_STANDARD 23)
|
|||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
||||
-Wno-missing-field-initializers -Wno-narrowing)
|
||||
|
||||
# get git commit
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE GIT_SHORT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND git rev-parse --short HEAD
|
||||
)
|
||||
|
||||
# get git commit of v$VERSION
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE GIT_TAG_SHORT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND git rev-parse --short v${VERSION}
|
||||
)
|
||||
|
||||
|
||||
add_compile_definitions(HYPRLOCK_VERSION="${VERSION}")
|
||||
add_compile_definitions(HYPRLOCK_COMMIT="${GIT_SHORT_HASH}")
|
||||
add_compile_definitions(HYPRLOCK_VERSION_COMMIT="${GIT_TAG_SHORT_HASH}")
|
||||
|
||||
if (DEFINED HYPRLOCK_COMMIT)
|
||||
add_compile_definitions(HYPRLOCK_COMMIT="${HYPRLOCK_COMMIT}")
|
||||
else()
|
||||
# get git commit
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE GIT_SHORT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND git rev-parse --short HEAD
|
||||
)
|
||||
add_compile_definitions(HYPRLOCK_COMMIT="${GIT_SHORT_HASH}")
|
||||
endif()
|
||||
|
||||
if (DEFINED HYPRLOCK_VERSION_COMMIT)
|
||||
add_compile_definitions(HYPRLOCK_VERSION_COMMIT="${HYPRLOCK_VERSION_COMMIT}")
|
||||
else()
|
||||
# get git commit of v$VERSION
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE GIT_TAG_SHORT_HASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND git rev-parse --short v${VERSION}
|
||||
)
|
||||
add_compile_definitions(HYPRLOCK_VERSION_COMMIT="${GIT_TAG_SHORT_HASH}")
|
||||
endif()
|
||||
|
||||
message(STATUS "VERSION COMMIT: ${HYPRLOCK_VERSION_COMMIT}")
|
||||
message(STATUS "COMMIT: ${HYPRLOCK_COMMIT}")
|
||||
|
||||
# position independent build: __FILE__
|
||||
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
||||
|
|
|
@ -60,7 +60,7 @@ stdenv.mkDerivation {
|
|||
|
||||
cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
|
||||
HYPRLOCK_COMMIT = shortRev;
|
||||
HYPRLOCK_VERSION_COMMIT = shortRev;
|
||||
HYPRLOCK_VERSION_COMMIT = ""; # Intentionally left empty (hyprlock --version will always print the commit)
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
|
Loading…
Reference in a new issue