Fix constexpr reinterpret_cast: patch user_dictionary.h at build time

This commit is contained in:
afiqzudinhadi 2026-06-22 22:52:40 +08:00
parent efbebfd1d2
commit 13e873414b
2 changed files with 33 additions and 0 deletions

View file

@ -3,6 +3,28 @@ if(CONFIG_ZMK_JAVELIN_STENO)
# Only compile on central side of split keyboards (or non-split)
if((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
# Apply patches to javelin source (removes constexpr from reinterpret_cast sites)
set(JAVELIN_PATCH_DIR "${CMAKE_CURRENT_LIST_DIR}/patches")
set(JAVELIN_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/javelin")
if(EXISTS "${JAVELIN_PATCH_DIR}" AND EXISTS "${JAVELIN_SRC_DIR}")
file(GLOB JAVELIN_PATCHES "${JAVELIN_PATCH_DIR}/*.patch")
foreach(PATCH ${JAVELIN_PATCHES})
execute_process(
COMMAND git apply --check ${PATCH}
WORKING_DIRECTORY ${JAVELIN_SRC_DIR}
RESULT_VARIABLE PATCH_CHECK_RESULT
ERROR_QUIET
)
if(PATCH_CHECK_RESULT EQUAL 0)
execute_process(
COMMAND git apply ${PATCH}
WORKING_DIRECTORY ${JAVELIN_SRC_DIR}
)
message(STATUS "Javelin steno: applied patch ${PATCH}")
endif()
endforeach()
endif()
zephyr_include_directories(javelin)
zephyr_include_directories(include)

View file

@ -0,0 +1,11 @@
--- a/dictionary/user_dictionary.h
+++ b/dictionary/user_dictionary.h
@@ -15,7 +15,7 @@
struct StenoUserDictionaryData {
StenoUserDictionaryData() = default;
- constexpr StenoUserDictionaryData(const uint8_t *mem, size_t size) {
+ StenoUserDictionaryData(const uint8_t *mem, size_t size) {
assert((size & (size - 1)) == 0);
hashTable = (uint32_t *)mem;
reverseHashTable = (const uint32_t *)(mem + size / 8);