fix(build): generate lexer headers before embind compile — fresh-build CI failed

pcbnew_embind.cpp pulls kicad_clipboard.h -> pcb_io_kicad_sexpr_parser.h ->
pcb_lexer.h, a header GENERATED during make (make_lexer custom command on the
pcbcommon target). The embind compile runs right after CMake configure, so on
a fresh build dir the header doesn't exist yet — the ephemeral Hetzner main CI
(run 27327303032) died on it in minutes. Local/incremental dirs already had the
header, which is why 9dbfddc's -I${KICAD_BUILD}/common alone seemed sufficient.

Pre-build pcbcommon before compiling the bindings: make resolves the real
dependency graph (no duplicated lexer-generator args), the app target needs
pcbcommon anyway so total build time is unchanged, and incrementally it's a
no-op. Verified by deleting pcb_lexer.h/pcb_keywords.cpp/pcbnew_embind.o inside
the docker build-cache volume and rebuilding: pre-build regenerates the header
before the embind compile succeeds.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Istvan Matejcsok 2026-06-11 08:57:23 +02:00
commit f936eb17b0

View file

@ -392,6 +392,15 @@ emcmake cmake "${KICAD_DIR}" \
# When no app-specific source exists, build an empty object so the linker line # When no app-specific source exists, build an empty object so the linker line
# referencing ${APP_NAME}_embind.o doesn't break. # referencing ${APP_NAME}_embind.o doesn't break.
if [ -f "${EMBIND_SRC}" ]; then if [ -f "${EMBIND_SRC}" ]; then
# pcbnew's embind TU transitively includes generated lexer headers
# (kicad_clipboard.h → pcb_io_kicad_sexpr_parser.h → pcb_lexer.h, emitted into
# ${KICAD_BUILD}/common by make_lexer custom commands on the pcbcommon target).
# On a fresh build dir they don't exist until make runs — build pcbcommon first.
# No wasted work: the app target depends on pcbcommon anyway; incremental no-op.
if [ "${APP_NAME}" = "pcbnew" ]; then
log_info "Pre-building pcbcommon so generated lexer headers exist for the embind compile..."
emmake make -j${JOBS} pcbcommon
fi
log_info "Compiling Embind bindings (${APP_NAME})..." log_info "Compiling Embind bindings (${APP_NAME})..."
# Use the same includes and flags that KiCad uses # Use the same includes and flags that KiCad uses
KICAD_INCLUDES="-I${KICAD_BUILD} -I${KICAD_DIR}/include -I${KICAD_DIR}/${KICAD_SUBDIR} -I${KICAD_DIR}/common" KICAD_INCLUDES="-I${KICAD_BUILD} -I${KICAD_DIR}/include -I${KICAD_DIR}/${KICAD_SUBDIR} -I${KICAD_DIR}/common"