refactor(build): vendor prost output, drop build.rs#49
Merged
Conversation
Move `.proto` -> Rust code generation from a per-build build script to a
maintainer-only tool at `tools/gen-proto/`. The generated file is now
checked in at `src/proto/generated/sketchlib.v1.rs`, so the published
crate is pure Rust:
- downstream `cargo build` no longer compiles `prost-build`,
`protoc-bin-vendored`, or any of their ~30 transitive deps;
- no `protoc` is required at build time;
- `[build-dependencies]` is now empty;
- `Cargo.lock` shrinks by ~280 lines.
Maintainers regenerate after editing any `proto/**/*.proto` with:
cargo run --manifest-path tools/gen-proto/Cargo.toml
A new CI job `proto-vendored-up-to-date` runs the generator and rejects
any pull request whose committed `src/proto/generated/` does not match
the result.
The `cross_language_proto` integration test continues to pass,
confirming the vendored types are byte-equivalent to the previous
build-time output.
Co-authored-by: Cursor <cursoragent@cursor.com>
The proto-vendored-up-to-date job invokes the regenerator with
`--locked` so that CI uses the exact same `prost-build` version the
maintainer used when committing `src/proto/generated/`. Without a
checked-in lockfile this fails immediately with:
error: cannot create the lock file ... because --locked was passed
Track `tools/gen-proto/Cargo.lock` via an explicit allow-list override
in `.gitignore` (the global `Cargo.lock` rule keeps applying to the
main crate's lockfile, but is intentionally negated for the
maintainer-only tool).
Co-authored-by: Cursor <cursoragent@cursor.com>
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
Switch the crate's protobuf code generation from a per-build script to a
vendored / checked-in model. Downstream users now get the prost-generated
Rust types directly in the crate; they no longer need
protocor any[build-dependencies]to buildasap_sketchlib.What changes for downstream users
cargo add asap_sketchlibno longer pullsprost-buildorprotoc-bin-vendored, nor any of their ~30 transitive deps.crate::proto::sketchlib::*is byte-equivalent tothe previous build-time output (verified by the existing
cross_language_prototest).What changes for maintainers
Source of truth is still
proto/**/*.proto.After editing any
.proto, regenerate the vendored output with:A new CI job
proto-vendored-up-to-dateruns the generator and fails thePR if
git diff --exit-code -- src/proto/generatedshows drift.File-level changes
build.rs.tools/gen-proto/— standalone (publish = false, own[workspace]) maintainer tool that drivesprost-build+protoc-bin-vendoredand writes tosrc/proto/generated/. Because it hasits own
Cargo.toml, Cargo automatically excludes the directory from thepublished tarball.
src/proto/generated/sketchlib.v1.rs— the vendored prost output(652 lines).
src/proto.rs—include!now points at the vendored path;the rustfmt/clippy attributes moved from inner attributes inside the
generated file (illegal in an
include!expansion) to outer attributes onthe wrapping
pub mod sketchlib.Cargo.toml— removed[build-dependencies], added anexplanatory comment.
Cargo.lock— ~280 lines (~30 transitive crates) dropped..github/workflows/ci.yml— added theproto-vendored-up-to-datejob..github/workflows/docs.yml—pathsfilter swapsbuild.rsfortools/gen-proto/**.README.mdanddocs/library_map.mdto describe the newgeneration workflow.
Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --all-features --locked(including thecross_language_protoroundtrip test that validates wire-formatcompatibility with
sketchlib-go)RUSTDOCFLAGS=-D warnings cargo doc --no-deps --all-features --lockedcargo package --list --allow-dirtyconfirmstools/gen-proto/isnot shipped to crates.io and
src/proto/generated/sketchlib.v1.rsis.cargo metadata --no-depsconfirmstools/gen-protois not amember of the
asap_sketchlibworkspace.Made with Cursor