Compare commits

...

5 Commits

Author SHA1 Message Date
pull[bot] 3cf75ea666
Merge 28a63989ab into c43582e917 2024-05-02 13:52:33 +00:00
Brenden Matthews 28a63989ab shared_ptr::unique() deprecated, use use_count()
unique() was deprecated in C++17, replace it with use_count(). We don't
need to worry about a race condition here.
2024-05-02 09:52:30 -04:00
Brenden Matthews 71ff774a44 Ensure we use correct LLVM in nix dev shell 2024-05-02 08:32:38 -04:00
Brenden Matthews 1352c28d1b Change debug message level 2024-05-02 08:32:22 -04:00
Brenden Matthews d6a6aadc5c Add BUILD_COLOUR_NAME_MAP build flag
You can now specify `BUILD_COLOUR_NAME_MAP=OFF` to disable building the
gperf-based colour map, which also removes the requirement for gperf at
build time.
2024-05-02 08:32:22 -04:00
8 changed files with 67 additions and 22 deletions

View File

@ -153,12 +153,6 @@ if(NOT APP_UNAME)
message(FATAL_ERROR "Unable to find program 'uname'")
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)
@ -169,7 +163,7 @@ if(NOT RELEASE)
mark_as_advanced(APP_GIT)
endif(NOT RELEASE)
mark_as_advanced(APP_AWK APP_WC APP_UNAME APP_GPERF)
mark_as_advanced(APP_AWK APP_WC APP_UNAME)
execute_process(COMMAND ${APP_UNAME} -sm
RESULT_VARIABLE RETVAL

View File

@ -67,6 +67,8 @@ option(BUILD_EXTRAS "Build extras (includes syntax files for editors)" false)
option(BUILD_I18N "Enable if you want internationalization support" true)
option(BUILD_COLOUR_NAME_MAP "Include mappings of colour name -> RGB (i.e., red -> ff0000)" true)
if(BUILD_I18N)
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale"
CACHE STRING "Directory containing the locales")

View File

@ -510,7 +510,7 @@ if(BUILD_LUA_CAIRO)
set(luacairo_libs ${CAIROXLIB_LIBRARIES} ${luacairo_libs})
set(luacairo_includes ${CAIROXLIB_INCLUDE_DIRS} ${luacairo_includes})
endif(BUILD_LUA_CAIRO_XLIB)
find_program(APP_PATCH patch)
if(NOT APP_PATCH)
@ -669,6 +669,16 @@ if(BUILD_DOCS OR BUILD_EXTRAS)
endif()
endif(BUILD_DOCS OR BUILD_EXTRAS)
if(BUILD_COLOUR_NAME_MAP)
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)
mark_as_advanced(APP_GPERF)
endif(BUILD_COLOUR_NAME_MAP)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG true)
endif(CMAKE_BUILD_TYPE MATCHES "Debug")

View File

@ -142,6 +142,8 @@
#cmakedefine BUILD_HSV_GRADIENT 1
#cmakedefine BUILD_COLOUR_NAME_MAP 1
#cmakedefine HAVE_STATFS64 1
#ifndef HAVE_STATFS64
#define statfs64 statfs

View File

@ -30,20 +30,25 @@
default = conky;
};
apps.conky = flake-utils.lib.mkApp {drv = packages.conky;};
apps.default = apps.conky;
devShells.default = mkShell {
buildInputs =
packages.conky.buildInputs
++ packages.conky.nativeBuildInputs
++ [
alejandra # for beautifying flake
lefthook # for git hooks
nodejs # for web/ stuff
# for docs
(python3.withPackages (ps: with ps; [jinja2]))
];
apps.conky = flake-utils.lib.mkApp {
drv = packages.conky;
};
apps.default = apps.conky;
devShells.default =
mkShell.override {
stdenv = llvmPackages_18.libcxxStdenv;
} rec {
buildInputs =
packages.conky.buildInputs
++ packages.conky.nativeBuildInputs
++ [
alejandra # for beautifying flake
lefthook # for git hooks
nodejs # for web/ stuff
# for docs
(python3.withPackages (ps: with ps; [jinja2]))
];
};
}
)
// {

28
src/colour-names-stub.hh Normal file
View File

@ -0,0 +1,28 @@
/*
* 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).
*/
#pragma once
#include <cstdint>
#include "logging.h"
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) {
DBGP2("color parsing not supported");
return nullptr;
}

View File

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

View File

@ -140,7 +140,7 @@ void run_all_callbacks() {
if (cb.remaining-- == 0) {
/* run the callback as long as someone holds a pointer to it;
* if no one owns the callback, run it at most UNUSED_MAX times */
if (!i->unique() || ++cb.unused < UNUSED_MAX) {
if (i->use_count() > 1 || ++cb.unused < UNUSED_MAX) {
cb.remaining = cb.period - 1;
cb.run();
if (cb.wait) { ++wait; }