Compare commits

...

5 Commits

Author SHA1 Message Date
Brenden Matthews bbc6193014 Docker: Add gperf, enable Lua Cairo Xlib bindings 2024-04-28 18:41:41 -04:00
Brenden Matthews 10045ab9f1 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.
2024-04-28 18:27:34 -04:00
Brenden Matthews 777b9a8dd7 Simplify binary include handling (and fix build) 2024-04-28 16:50:15 -04:00
Brenden Matthews ef3ed8c1dc Include these when linting 2024-04-28 15:22:59 -04:00
Brenden Matthews 7598b89960 Disable -Wregister on gperf output
Older versions of gperf use the `register` keyword which is deprecated
in C++17, and warnings are treated as errors.

This disables the warning on gperf's output (colour-names.hh). I also
renamed `colour-names.cc` -> `colour-names.hh` because we're including
it as a header, not compiling it separately.

This resolves #1865.
2024-04-28 15:22:59 -04:00
7 changed files with 35 additions and 51 deletions

2
.gitignore vendored
View File

@ -23,7 +23,7 @@ data/defconfig.h
*.a
/config.h
/build.h
src/colour-names.cc
src/colour-names.hh
# Compiler cache
.cache

View File

@ -9,6 +9,7 @@ RUN apt-get update \
curl \
gfortran \
git \
gperf \
libarchive-dev \
libaudclient-dev \
libc++-dev \
@ -74,6 +75,7 @@ RUN sh -c 'if [ "$X11" = "yes" ] ; then \
-DBUILD_IRC=ON \
-DBUILD_JOURNAL=ON \
-DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_CAIRO_XLIB=ON \
-DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=ON \
-DBUILD_MYSQL=ON \

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

@ -11,7 +11,7 @@ pre-commit:
run: |
clang-format -i {staged_files} \
&& git add {staged_files}
glob: '*.{c,cc,cxx,h,cpp}'
glob: '*.{c,cc,cxx,h,hh,cpp}'
misc-linter:
run: |
npx -y prettier --write {staged_files} \

View File

@ -20,6 +20,9 @@
include_directories(${conky_includes})
# always include the binary dir
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(BUILD_BUILTIN_CONFIG OR BUILD_OLD_CONFIG)
# include config output dir
include_directories(${CMAKE_BINARY_DIR}/data)
@ -47,22 +50,17 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/defconfig.h)
)
endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/defconfig.h)
# Generate colour-names.cc 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_BINARY_DIR}/colour-names.cc"
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.cc; colors names will not be parsed")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/colour-names-stub.cc" "${CMAKE_BINARY_DIR}/colour-names.cc" COPYONLY)
endif(APP_GPERF)
# Generate colour-names.hh with 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}
@ -253,7 +251,7 @@ endif(BUILD_HTTP)
if(BUILD_X11)
set(x11
display-x11.cc
display-x11.cc
display-x11.hh
x11-settings.cc
x11-settings.h
@ -274,11 +272,10 @@ if(BUILD_GUI)
endif(BUILD_MOUSE_EVENTS OR BUILD_XINPUT)
endif(BUILD_GUI)
if(BUILD_WAYLAND)
set(wl_srcs
wl.cc
wl.h
wl.h
display-wayland.cc
display-wayland.hh
xdg-shell-protocol.c
@ -304,9 +301,6 @@ if(BUILD_WAYLAND)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wlr-layer-shell-protocol.c
COMMAND ${Wayland_SCANNER} private-code ${WLR_LAYER_SHELL_PROT_DEF} wlr-layer-shell-protocol.c
DEPENDS wlr-layer-shell-client-protocol.h)
# include output dir in include path
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif(BUILD_WAYLAND)
if(BUILD_HDDTEMP)
@ -356,10 +350,10 @@ endif(BUILD_ICONV)
if(BUILD_NCURSES)
set(ncurses_srcs
nc.cc
nc.h
display-ncurses.cc
display-ncurses.hh
nc.cc
nc.h
display-ncurses.cc
display-ncurses.hh
)
set(optional_sources ${optional_sources} ${ncurses_srcs})
endif(BUILD_NCURSES)

View File

@ -1,22 +0,0 @@
/*
* To generate colour-names.cc, 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;
}

View File

@ -42,7 +42,13 @@ Colour Colour::from_argb32(uint32_t argb) {
return out;
}
#include "colour-names.cc"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wregister"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wregister"
#include <colour-names.hh>
#pragma clang diagnostic pop
#pragma GCC diagnostic pop
std::optional<Colour> parse_color_name(const std::string &name) {
const rgb *value = color_name_hash::in_word_set(name.c_str(), name.length());