Fix: split build - Javelin lib (C++23) + bridge sources in app target (ZMK headers)

This commit is contained in:
afiqzudinhadi 2026-06-22 23:39:11 +08:00
parent bbb17c58d9
commit 95e73ee2b8
3 changed files with 17 additions and 5 deletions

View file

@ -199,14 +199,18 @@ print(f'Stripped test blocks from {count} files')
src/engine_init.cc src/engine_init.cc
) )
# Combine all C++ sources # Pure Javelin sources (no ZMK deps) → separate library for C++23
set(ALL_CXX_SRC set(JAVELIN_LIB_SRC
${JAVELIN_CORE_SRC} ${JAVELIN_CORE_SRC}
${JAVELIN_DICT_SRC} ${JAVELIN_DICT_SRC}
${JAVELIN_PROC_SRC} ${JAVELIN_PROC_SRC}
${JAVELIN_HAL_SRC} ${JAVELIN_HAL_SRC}
${JAVELIN_FONT_SRC} ${JAVELIN_FONT_SRC}
${JAVELIN_SPLIT_SRC} ${JAVELIN_SPLIT_SRC}
)
# Shims + init (need ZMK headers) → compiled into app target
set(ZMK_BRIDGE_SRC
${ZMK_SHIM_SRC} ${ZMK_SHIM_SRC}
${ZMK_INIT_SRC} ${ZMK_INIT_SRC}
) )
@ -214,7 +218,7 @@ print(f'Stripped test blocks from {count} files')
# Build Javelin as a separate static library so we can control # Build Javelin as a separate static library so we can control
# C++ standard without Zephyr's -std=c++11 interfering. # C++ standard without Zephyr's -std=c++11 interfering.
zephyr_library_named(javelin_steno) zephyr_library_named(javelin_steno)
zephyr_library_sources(${ALL_CXX_SRC}) zephyr_library_sources(${JAVELIN_LIB_SRC})
zephyr_library_compile_options( zephyr_library_compile_options(
-std=gnu++23 -std=gnu++23
-fno-exceptions -fno-exceptions
@ -233,8 +237,14 @@ print(f'Stripped test blocks from {count} files')
# Test suppression handled by include/javelin_overrides/unit_test.h # Test suppression handled by include/javelin_overrides/unit_test.h
# which shadows Javelin's unit_test.h via include path ordering. # which shadows Javelin's unit_test.h via include path ordering.
# Bridge sources (C++ with ZMK headers) compiled into app target
set_source_files_properties(${ZMK_BRIDGE_SRC} PROPERTIES
COMPILE_FLAGS "-std=gnu++23 -fno-exceptions -fno-rtti -fno-threadsafe-statics -fpermissive"
)
target_sources(app PRIVATE target_sources(app PRIVATE
${ZMK_BEHAVIOR_SRC} ${ZMK_BEHAVIOR_SRC}
${ZMK_BRIDGE_SRC}
) )
# Dictionary binary embedding. # Dictionary binary embedding.

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -7,7 +9,6 @@ extern "C" {
void zmk_javelin_steno_init(void); void zmk_javelin_steno_init(void);
void zmk_javelin_steno_process_key(int steno_key_index, bool is_press); void zmk_javelin_steno_process_key(int steno_key_index, bool is_press);
// Linker symbols for the embedded dictionary binary
extern const uint8_t _javelin_dict_start[]; extern const uint8_t _javelin_dict_start[];
extern const uint8_t _javelin_dict_end[]; extern const uint8_t _javelin_dict_end[];

View file

@ -1,8 +1,9 @@
#include "key.h" #include "key.h"
#include "key_code.h" #include "key_code.h"
extern "C" {
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
extern "C" {
#include <zmk/event_manager.h> #include <zmk/event_manager.h>
#include <zmk/events/keycode_state_changed.h> #include <zmk/events/keycode_state_changed.h>
} }