1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-06-10 11:12:21 +00:00

Require gperf at build-time

Rather than allowing the build to continue without gperf, we should
fail with an error so that the colour behaviour does not change in a
backward incompatible manner. The old colour behaviour should continue
to work going forward.

This resolves #1868.
This commit is contained in:
Brenden Matthews 2024-04-28 16:53:28 -04:00
parent 777b9a8dd7
commit 10045ab9f1
3 changed files with 14 additions and 37 deletions

View File

@ -155,6 +155,10 @@ endif(NOT APP_UNAME)
find_program(APP_GPERF gperf)
if(NOT APP_GPERF)
message(FATAL_ERROR "Unable to find program 'gperf' (required at build-time as of Conky v1.20.2)")
endif(NOT APP_GPERF)
if(NOT RELEASE)
find_program(APP_GIT git)

View File

@ -51,21 +51,16 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/defconfig.h)
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/defconfig.h)
# Generate colour-names.hh with gperf
if(APP_GPERF)
execute_process(
INPUT_FILE "${CMAKE_SOURCE_DIR}/data/color-names.yml"
OUTPUT_FILE "${CMAKE_BINARY_DIR}/data/color-names.gperf"
COMMAND sh "${CMAKE_SOURCE_DIR}/bin/format-colors.sh"
)
execute_process(
INPUT_FILE "${CMAKE_BINARY_DIR}/data/color-names.gperf"
OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/colour-names.hh"
COMMAND ${APP_GPERF} --ignore-case -LC++ -Zcolor_name_hash -t -7 -m1 -C -E
)
else(APP_GPERF)
message(WARNING "'gperf' program not found, using stub colour-names.hh; colors names will not be parsed")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/colour-names-stub.hh" "${CMAKE_CURRENT_BINARY_DIR}/colour-names.hh" COPYONLY)
endif(APP_GPERF)
execute_process(
INPUT_FILE "${CMAKE_SOURCE_DIR}/data/color-names.yml"
OUTPUT_FILE "${CMAKE_BINARY_DIR}/data/color-names.gperf"
COMMAND sh "${CMAKE_SOURCE_DIR}/bin/format-colors.sh"
)
execute_process(
INPUT_FILE "${CMAKE_BINARY_DIR}/data/color-names.gperf"
OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/colour-names.hh"
COMMAND ${APP_GPERF} --ignore-case -LC++ -Zcolor_name_hash -t -7 -m1 -C -E
)
set(conky_sources
${conky_sources}

View File

@ -1,22 +0,0 @@
/*
* To generate colour-names.hh, you must have gperf installed during build.
* This is a dummy implementation for builds without gperf.
* Color name matching will always return null (i.e. no match).
*/
struct rgb {
const char *name;
uint8_t red;
uint8_t green;
uint8_t blue;
};
class color_name_hash {
public:
static const struct rgb *in_word_set(const char *str, size_t len);
};
const struct rgb *color_name_hash::in_word_set(const char *str, size_t len) {
DBGP("color parsing not supported");
return nullptr;
}