Skip to content

Add macOS/newer-toolchain compatibility shims to codex sources - #1

Open
raulizahi wants to merge 1 commit into
10-X-eng:feature/codex-kicad-10from
raulizahi:feature/macos-build-compat
Open

Add macOS/newer-toolchain compatibility shims to codex sources#1
raulizahi wants to merge 1 commit into
10-X-eng:feature/codex-kicad-10from
raulizahi:feature/macos-build-compat

Conversation

@raulizahi

Copy link
Copy Markdown

Summary

Makes the codex/KDS sources compile on macOS (Apple clang / Homebrew toolchain) with zero intended behavior change on the qualified Ubuntu 24.04 platform. Three independent toolchain gaps are closed:

  1. kicad/codex/kichad_from_chars.h — Apple's libc++ implements only the integer overloads of std::from_chars. KICHAD::FromChars forwards to std::from_chars on every non-Apple platform; on Apple, floating-point input parses through the repo's bundled fast_float (the same dependency upstream already uses in common/dsnlexer.cpp). 64 call sites across 29 codex files switch to the shim; declarations and strictness checks are untouched. long double sites lose nothing on arm64 macOS, where long double is double.
  2. kicad/codex/kichad_protobuf_compat.h — protobuf 22+ replaced google::protobuf::util::Status with absl::Status, and protobuf 25+ renamed JsonPrintOptions::always_print_primitive_fields. PROTOBUF_STATUS derives the status type via decltype on MessageToJsonString, and SetAlwaysPrintDefaultValuedFields() assigns whichever options member exists — both compile against Ubuntu 24.04's protobuf 3.21 and current protobuf 33 without version conditionals.
  3. codex_tool_support.cpp — one descriptor json_name() concatenation wrapped in std::string(...) for protobuf's absl::string_view accessor change.

The QA test test_design_script_pcb_planner.cpp picks up the same PROTOBUF_STATUS alias.

Validation

  • Full build on macOS 14.8 arm64 (Apple clang 15, Homebrew deps, Boost pinned to 1.85 for Boost.Process v1): all 3,045 targets compile and link; kicad-cli reports 10.0.4-…-KiChad.
  • qa_common on macOS: passes except known environment-dependent cases (live-editor IPC, headless clipboard/pasteboard, network fetches, one /var symlink path comparison, one timing-flaky pipe test) — details in the branch discussion.
  • GUI + embedded Codex panel launch and connect on macOS with a host codex.
  • Linux is unaffected by construction: every shim resolves to the exact pre-change expression outside __APPLE__ / current-protobuf builds. A Linux CI run should confirm.

🤖 Generated with Claude Code

Apple's libc++ ships integer-only std::from_chars, and Homebrew's
current protobuf (33) renamed or removed several util APIs the codex
tools use. Both gaps are closed with header shims that keep the
qualified Linux behavior bit-for-bit unchanged:

- kichad_from_chars.h: KICHAD::FromChars forwards to std::from_chars
  everywhere except Apple floating point, which parses via the bundled
  fast_float (the same dependency dsnlexer already uses). 64 call
  sites across 29 codex files switch to the shim.
- kichad_protobuf_compat.h: PROTOBUF_STATUS derives the JSON-util
  status type via decltype (util::Status vs absl::Status), and
  SetAlwaysPrintDefaultValuedFields assigns whichever JsonPrintOptions
  member the protobuf generation provides.
- codex_tool_support.cpp wraps a descriptor json_name() concatenation
  in std::string() for protobuf's absl::string_view accessors.

Compiled clean on macOS 14 arm64 (Apple clang, Homebrew deps) and
qa_common passes there except cases needing a live editor, clipboard,
or network. No Linux behavior change intended.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds small, localized compatibility shims so the kicad/codex sources compile cleanly on macOS (Apple clang/libc++ and newer Homebrew protobuf), while aiming to preserve behavior on the qualified Ubuntu 24.04 toolchain.

Changes:

  • Introduces KICHAD::FromChars to provide a floating-point parsing fallback on Apple libc++ (via bundled fast_float) and updates codex parsers to use it.
  • Introduces kicad_protobuf_compat.h to abstract protobuf Status and JSON print option member renames across protobuf generations, and updates codex/tools/tests to use the shim.
  • Applies a small protobuf json_name() string conversion tweak for descriptor JSON output.

Reviewed changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
qa/tests/common/test_design_script_pcb_planner.cpp Uses KICHAD::PROTOBUF_STATUS for protobuf-version portability in QA JSON parsing.
kicad/codex/kichad_protobuf_compat.h New protobuf compatibility shim for Status type and JSON print option field rename.
kicad/codex/kichad_from_chars.h New std::from_chars shim with Apple floating-point fallback via fast_float.
kicad/codex/codex_tool_support.cpp Uses protobuf compat shim; adjusts json_name() handling and status typing.
kicad/codex/codex_tool_pcb.cpp Uses protobuf compat shim for JSON serialization status typing.
kicad/codex/codex_tool_design.cpp Uses protobuf compat shim for status typing and default-valued field printing option.
kicad/codex/design_script_compiler.cpp Switches floating-point parsing to KICHAD::FromChars for macOS toolchain compatibility.
kicad/codex/design_script_board_asset_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_board_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_board_table_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_electrical_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_custom_pad_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_graphic_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_hole_treatment_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_pad_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_padstack_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_property_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_settings_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_text_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_footprint_zone_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_layout_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_physical_synthesizer.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_physical_synthesis_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_production_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_simulation_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_symbol_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_symbol_field_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_symbol_graphics_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_symbol_resolver.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_symbol_text_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_teardrop_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_via_backdrill_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_via_padstack_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.
kicad/codex/design_script_via_protection_compiler.cpp Switches floating-point parsing to KICHAD::FromChars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +47
if constexpr( std::is_floating_point_v<T> )
{
double parsed = 0.0;
fast_float::from_chars_result result = fast_float::from_chars( aFirst, aLast, parsed );

if( result.ec == std::errc() )
aValue = static_cast<T>( parsed );

return std::from_chars_result{ result.ptr, result.ec };
}
Comment on lines +12 to 13
#include "kichad_from_chars.h"
#include "design_script_production_compiler.h"
Comment on lines +5024 to +5027
fieldDescription["expandWith"] =
normalizedPath.empty()
? std::string( field->json_name() )
: normalizedPath + '.' + std::string( field->json_name() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants