From f936eb17b04a3279f91d17d6611e4625be9a93bf Mon Sep 17 00:00:00 2001 From: Istvan Matejcsok <119620946+matejcsok-ee@users.noreply.github.com> Date: Thu, 11 Jun 2026 08:57:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(build):=20generate=20lexer=20headers=20befo?= =?UTF-8?q?re=20embind=20compile=20=E2=80=94=20fresh-build=20CI=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/kicad/build-kicad-target.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/kicad/build-kicad-target.sh b/scripts/kicad/build-kicad-target.sh index c322f0d..7d0e94c 100755 --- a/scripts/kicad/build-kicad-target.sh +++ b/scripts/kicad/build-kicad-target.sh @@ -392,6 +392,15 @@ emcmake cmake "${KICAD_DIR}" \ # When no app-specific source exists, build an empty object so the linker line # referencing ${APP_NAME}_embind.o doesn't break. 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})..." # 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"