Skip to content

Commit

Permalink
Use perfect hash (gperf) for parsing color names (#1848)
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian authored Apr 24, 2024
1 parent 6adf6b9 commit 93ffab5
Show file tree
Hide file tree
Showing 16 changed files with 865 additions and 1,659 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
audacious-dev \
cmake \
gawk \
gperf \
lcov \
libaudclient-dev \
libcairo2-dev \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
freetype \
gettext \
imlib2 \
gperf \
lcov \
librsvg \
libxft \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
audacious-dev \
cmake \
gawk \
gperf \
lcov \
libaudclient-dev \
libc++-14-dev \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
audacious-dev \
cmake \
gawk \
gperf \
lcov \
libaudclient-dev \
libcairo2-dev \
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ cmake_uninstall.cmake
CPackConfig.cmake
CPackSourceConfig.cmake

# Generated files
data/convertconf.h
data/defconfig.h
*.so
*.a
/config.h
/build.h
src/colour-names.cc

# Compiler cache
.cache
Expand Down
7 changes: 7 additions & 0 deletions bin/format-colors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Prepares stdin input YAML for gperf consumption

echo "struct rgb { const char *name; uint8_t red; uint8_t green; uint8_t blue; };"
echo "%%"
tr -d '[]"' | tr ":" ","
4 changes: 3 additions & 1 deletion cmake/Conky.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ if(NOT APP_UNAME)
message(FATAL_ERROR "Unable to find program 'uname'")
endif(NOT APP_UNAME)

find_program(APP_GPERF gperf)

if(NOT RELEASE)
find_program(APP_GIT git)

Expand All @@ -163,7 +165,7 @@ if(NOT RELEASE)
mark_as_advanced(APP_GIT)
endif(NOT RELEASE)

mark_as_advanced(APP_AWK APP_WC APP_UNAME)
mark_as_advanced(APP_AWK APP_WC APP_UNAME APP_GPERF)

execute_process(COMMAND ${APP_UNAME} -sm
RESULT_VARIABLE RETVAL
Expand Down
Loading

0 comments on commit 93ffab5

Please sign in to comment.