mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-22 00:12:34 +00:00
fix(codegen): drop grpcio-tools, stop committing generated code
The codegen only ever needed a protoc binary, but every entry point installed
grpcio-tools to get one. That drags in the grpcio C extension, which has no
Windows/ARM64 wheel and falls back to building from source there, so the ARM64
job died with "Failed building wheel for grpcio" -> "protoc not found".
tools/codegen_toolchain.py resolves the toolchain instead: protoc from $PROTOC,
PATH, a cache, grpc_tools when already installed, or a pinned checksum-verified
protoc release unpacked into .codegen-tools/; protobuf and pyyaml from the
calling interpreter or a cached virtualenv it re-execs into (distro Pythons
refuse `pip install` under PEP 668). All four build scripts and all three CI
jobs are now just `python tools/run_codegen.py`, with no pip lines around it.
tools/config_metadata_pb2.py was the one generated file checked into git. The
orca.* option extensions are now read out of the descriptor set, which already
carries config_metadata.proto via --include_imports, so nothing is generated
into the tree -- and the protobuf>=6.33.5,<7 CI pin goes away with it, since it
only existed to satisfy gencode's hard ValidateProtobufRuntimeVersion check.
Generated C++ verified byte-identical under upb and the pure-Python protobuf
runtime (what win/arm64 installs), and under both grpc_tools' and standalone
protoc.
Also fixed:
- build_release_macos.sh still passed -DPython3_EXECUTABLE=<codegen venv>,
pointing the bundled *embed* interpreter at the codegen environment -- the
same confusion fae4b124 fixed on the CMake side.
- Tab.cpp #includes TabLayout_generated.cpp but had no dependency on
codegen_config, so an incremental build after a .proto edit could compile it
while the file was being rewritten. libslic3r already had this guard.
- ConfigCodegen.cmake now probes with `codegen_toolchain.py --check` (which
never downloads or installs), prefers a host interpreter over the embed one,
and lets a fresh clone generate at configure time instead of erroring out.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
fae4b1241b
commit
2f67e46047
@@ -275,9 +275,9 @@ Settings are split into three `.proto` files by preset type. Each setting become
|
||||
|
||||
| File | Contents |
|
||||
|------|----------|
|
||||
| `src/PrintConfigs/generated/print.proto` | ~477 print/process settings |
|
||||
| `src/PrintConfigs/generated/filament.proto` | ~103 filament settings |
|
||||
| `src/PrintConfigs/generated/printer.proto` | ~42 printer settings |
|
||||
| `src/PrintConfigs/print.proto` | ~477 print/process settings |
|
||||
| `src/PrintConfigs/filament.proto` | ~103 filament settings |
|
||||
| `src/PrintConfigs/printer.proto` | ~42 printer settings |
|
||||
|
||||
Each file also carries message-level `virtual_preset_keys` declarations (see §5.2.3).
|
||||
|
||||
@@ -364,13 +364,19 @@ The codegen reads these and merges them (deduplicated, sorted) with the field-de
|
||||
```cmake
|
||||
add_custom_command(
|
||||
OUTPUT ${GENERATED_SOURCES}
|
||||
COMMAND protoc --descriptor_set_out=config.desc src/PrintConfigs/generated/*.proto
|
||||
COMMAND python3 tools/config_codegen.py config.desc ${GENERATED_DIR}
|
||||
DEPENDS src/PrintConfigs/generated/*.proto tools/config_codegen.py
|
||||
COMMAND ${ORCA_CODEGEN_PYTHON} tools/run_codegen.py --no-validate
|
||||
DEPENDS src/PrintConfigs/*.proto src/PrintConfigs/layout.yaml tools/config_codegen.py
|
||||
)
|
||||
```
|
||||
|
||||
Generated files are checked into the repo (not gitignored) so builds work without `protoc`. CI validates that committed generated files match what the generator produces.
|
||||
Generated files are **not** checked into the repo — `src/slic3r/GUI/generated/` and `config.desc` are gitignored, and every build produces them. Each build script and CI job runs `tools/run_codegen.py` before configuring; a fresh clone that goes straight to `cmake` gets them generated at configure time.
|
||||
|
||||
`tools/run_codegen.py` resolves its own toolchain (`tools/codegen_toolchain.py`), so no caller has to install anything:
|
||||
|
||||
- **protoc** — `$PROTOC`, then `PATH`, then a cached copy, then a pinned checksum-verified release downloaded into `.codegen-tools/` (also gitignored)
|
||||
- **protobuf + pyyaml** — the calling interpreter if it has them, otherwise a virtualenv under `.codegen-tools/` that the script re-execs into
|
||||
|
||||
Set `PROTOC=<path>` to build offline or against a distro protoc.
|
||||
|
||||
### 4.5 Provider Customization
|
||||
|
||||
@@ -431,7 +437,7 @@ Custom options get field numbers > 1000 to avoid conflicts.
|
||||
|
||||
1. Add a field to the appropriate `.proto` file (`print.proto`, `filament.proto`, or `printer.proto`) with all relevant annotations
|
||||
2. Run `python tools/run_codegen.py`
|
||||
3. Commit the `.proto` change and the updated generated files together
|
||||
3. Commit the `.proto` change — the generated files are gitignored build output, never committed
|
||||
|
||||
### Adding a virtual preset key
|
||||
|
||||
@@ -461,26 +467,25 @@ python tools/annotate_protos.py [--dry-run]
|
||||
src/PrintConfigs/
|
||||
├── config_metadata.proto # Custom field/message option extensions
|
||||
├── layout.yaml # UI tab/page/group structure (Tab.cpp layout)
|
||||
└── generated/
|
||||
├── print.proto # ~477 print/process settings
|
||||
├── filament.proto # ~103 filament settings
|
||||
└── printer.proto # ~42 printer/machine settings
|
||||
├── print.proto # ~477 print/process settings
|
||||
├── filament.proto # ~103 filament settings
|
||||
└── printer.proto # ~42 printer/machine settings
|
||||
|
||||
tools/
|
||||
├── parse_printconfig.py # Bootstrap: PrintConfig.cpp → .proto
|
||||
├── run_codegen.py # Full pipeline script — the entry point everything calls
|
||||
├── codegen_toolchain.py # Resolves protoc / protobuf / pyyaml
|
||||
├── config_codegen.py # Proto descriptor → C++ codegen
|
||||
├── validate_codegen.py # Generated vs original validation
|
||||
├── run_codegen.py # Full pipeline script
|
||||
├── annotate_protos.py # Inject (invalidates)/(list_membership) from C++
|
||||
├── move_proto_fields.py # Utility: move fields between proto files
|
||||
└── config_metadata_pb2.py # Generated Python bindings for extensions
|
||||
├── config_metadata.py # Reads the orca.* option extensions from the descriptor set
|
||||
└── validate_codegen.py # Generated vs original validation
|
||||
|
||||
codegen/
|
||||
└── generated/
|
||||
├── PrintConfigDef_generated.cpp # init_fff_params() body — #included by PrintConfig.cpp
|
||||
├── Preset_options_generated.cpp # s_Preset_*_options — #included by Preset.cpp
|
||||
├── Invalidation_generated.cpp # s_print_steps_map + s_object_steps_map — #included by Print.cpp
|
||||
└── OptionKeys_generated.cpp # s_extruder_option_keys, s_filament_option_keys
|
||||
src/slic3r/GUI/generated/ # gitignored — regenerated by every build
|
||||
├── PrintConfigDef_generated.cpp # init_fff_params() body — #included by PrintConfig.cpp
|
||||
├── Preset_options_generated.cpp # s_Preset_*_options — #included by Preset.cpp
|
||||
├── Invalidation_generated.cpp # s_print_steps_map + s_object_steps_map — #included by Print.cpp
|
||||
├── OptionKeys_generated.cpp # s_extruder_option_keys, s_filament_option_keys
|
||||
└── TabLayout_generated.cpp # Tab page/group layout from layout.yaml
|
||||
|
||||
.codegen-tools/ # gitignored — downloaded protoc + bootstrap virtualenv
|
||||
|
||||
cmake/modules/
|
||||
└── ConfigCodegen.cmake # CMake integration (build-time regeneration)
|
||||
|
||||
Reference in New Issue
Block a user