Add macOS/newer-toolchain compatibility shims to codex sources - #1
Open
raulizahi wants to merge 1 commit into
Open
Add macOS/newer-toolchain compatibility shims to codex sources#1raulizahi wants to merge 1 commit into
raulizahi wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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::FromCharsto provide a floating-point parsing fallback on Apple libc++ (via bundledfast_float) and updates codex parsers to use it. - Introduces
kicad_protobuf_compat.hto abstract protobufStatusand 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() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
kicad/codex/kichad_from_chars.h— Apple's libc++ implements only the integer overloads ofstd::from_chars.KICHAD::FromCharsforwards tostd::from_charson every non-Apple platform; on Apple, floating-point input parses through the repo's bundledfast_float(the same dependency upstream already uses incommon/dsnlexer.cpp). 64 call sites across 29 codex files switch to the shim; declarations and strictness checks are untouched.long doublesites lose nothing on arm64 macOS, wherelong doubleisdouble.kicad/codex/kichad_protobuf_compat.h— protobuf 22+ replacedgoogle::protobuf::util::Statuswithabsl::Status, and protobuf 25+ renamedJsonPrintOptions::always_print_primitive_fields.PROTOBUF_STATUSderives the status type viadecltypeonMessageToJsonString, andSetAlwaysPrintDefaultValuedFields()assigns whichever options member exists — both compile against Ubuntu 24.04's protobuf 3.21 and current protobuf 33 without version conditionals.codex_tool_support.cpp— one descriptorjson_name()concatenation wrapped instd::string(...)for protobuf'sabsl::string_viewaccessor change.The QA test
test_design_script_pcb_planner.cpppicks up the samePROTOBUF_STATUSalias.Validation
kicad-clireports10.0.4-…-KiChad.qa_commonon macOS: passes except known environment-dependent cases (live-editor IPC, headless clipboard/pasteboard, network fetches, one/varsymlink path comparison, one timing-flaky pipe test) — details in the branch discussion.codex.__APPLE__/ current-protobuf builds. A Linux CI run should confirm.🤖 Generated with Claude Code