add cmake target for generating gperf hashmap

This commit is contained in:
Bharat Nallan Chakravarthy 2023-09-01 18:55:45 -07:00
parent 8711be533d
commit 48defd0556
3 changed files with 19 additions and 9 deletions

View File

@ -112,6 +112,24 @@ if (ENABLE_FUZZING)
add_compile_definitions(FUZZING_MODE=1)
endif ()
if (USE_GPERF)
# Only for regenerating
add_custom_target(generate-html-char-ref-gperf ./HTMLCharacterReference.sh
SOURCES ./HTMLCharacterReference.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
BYPRODUCTS "${CMAKE_CURRENT_SOURCE_DIR}/HTMLCharacterReference.gperf"
)
add_custom_target(generate-html-char-ref ${GPERF} -t HTMLCharacterReference.gperf --output-file=HTMLCharacterReference.generated.cpp && clang-format -i HTMLCharacterReference.generated.cpp
SOURCES HTMLCharacterReference.gperf
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(generate-html-char-ref generate-html-char-ref-gperf)
if (NOT TARGET generate-source)
add_custom_target(generate-source)
endif ()
add_dependencies(generate-source generate-html-char-ref)
endif ()
target_link_libraries(clickhouse_functions_obj PUBLIC ${PUBLIC_LIBS} PRIVATE ${PRIVATE_LIBS})
# Used to forward the linking information to the final binaries such as clickhouse / unit_tests_dbms,

View File

@ -1,5 +1,5 @@
/* C++ code produced by gperf version 3.1 */
/* Command-line: gperf -t --output-file=HTMLCharacterReference.generated.cpp HTMLCharacterReference.gperf */
/* Command-line: /usr/bin/gperf -t --output-file=HTMLCharacterReference.generated.cpp HTMLCharacterReference.gperf */
/* Computed positions: -k'1-8,12,14' */
#if !( \

8
src/Functions/HTMLCharacterReference.sh Normal file → Executable file
View File

@ -23,11 +23,3 @@ const char *glyph;
# character reference as available at https://html.spec.whatwg.org/multipage/named-characters.html
curl -X GET https://html.spec.whatwg.org/entities.json | jq -r 'keys[] as $k | "\"\($k)\", \(.[$k] | .characters|tojson)"' | sed 's/^"&/"/' >> HTMLCharacterReference.gperf
echo '%%' >> HTMLCharacterReference.gperf
if ! command -V gperf &> /dev/null
then
echo "error: gperf command not found. Install gperf to continue."
exit 1
fi;
gperf -t --output-file=HTMLCharacterReference.generated.cpp HTMLCharacterReference.gperf