mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-13 05:40:42 +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,6 +28,14 @@ set(CMAKE_CXX_STANDARD 23)
|
||||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value
|
||||||
-Wno-missing-field-initializers -Wno-narrowing)
|
-Wno-missing-field-initializers -Wno-narrowing)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_compile_definitions(HYPRLOCK_VERSION="${VERSION}")
|
||||||
|
|
||||||
|
if (DEFINED HYPRLOCK_COMMIT)
|
||||||
|
add_compile_definitions(HYPRLOCK_COMMIT="${HYPRLOCK_COMMIT}")
|
||||||
|
else()
|
||||||
# get git commit
|
# get git commit
|
||||||
execute_process(
|
execute_process(
|
||||||
OUTPUT_VARIABLE GIT_SHORT_HASH
|
OUTPUT_VARIABLE GIT_SHORT_HASH
|
||||||
|
@ -35,7 +43,12 @@ execute_process(
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND git rev-parse --short HEAD
|
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
|
# get git commit of v$VERSION
|
||||||
execute_process(
|
execute_process(
|
||||||
OUTPUT_VARIABLE GIT_TAG_SHORT_HASH
|
OUTPUT_VARIABLE GIT_TAG_SHORT_HASH
|
||||||
|
@ -43,10 +56,11 @@ execute_process(
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND git rev-parse --short v${VERSION}
|
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}")
|
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__
|
# position independent build: __FILE__
|
||||||
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
|
||||||
|
|
|
@ -60,7 +60,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
|
cmakeFlags = lib.mapAttrsToList lib.cmakeFeature {
|
||||||
HYPRLOCK_COMMIT = shortRev;
|
HYPRLOCK_COMMIT = shortRev;
|
||||||
HYPRLOCK_VERSION_COMMIT = shortRev;
|
HYPRLOCK_VERSION_COMMIT = ""; # Intentionally left empty (hyprlock --version will always print the commit)
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|
Loading…
Reference in a new issue