Skip to content

refactor(build): vendor prost output, drop build.rs#49

Merged
GordonYuanyc merged 2 commits into
mainfrom
vendor-proto-codegen
May 14, 2026
Merged

refactor(build): vendor prost output, drop build.rs#49
GordonYuanyc merged 2 commits into
mainfrom
vendor-proto-codegen

Conversation

@GordonYuanyc
Copy link
Copy Markdown
Collaborator

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 protoc or any
[build-dependencies] to build asap_sketchlib.

What changes for downstream users

  • cargo add asap_sketchlib no longer pulls prost-build or
    protoc-bin-vendored, nor any of their ~30 transitive deps.
  • No build script runs on their machine; the crate is pure Rust.
  • The public surface crate::proto::sketchlib::* is byte-equivalent to
    the previous build-time output (verified by the existing
    cross_language_proto test).

What changes for maintainers

  • Source of truth is still proto/**/*.proto.

  • After editing any .proto, regenerate the vendored output with:

    cargo run --manifest-path tools/gen-proto/Cargo.toml
    git add src/proto/generated
  • A new CI job proto-vendored-up-to-date runs the generator and fails the
    PR if git diff --exit-code -- src/proto/generated shows drift.

File-level changes

  • Deleted build.rs.
  • New tools/gen-proto/ — standalone (publish = false, own
    [workspace]) maintainer tool that drives prost-build +
    protoc-bin-vendored and writes to src/proto/generated/. Because it has
    its own Cargo.toml, Cargo automatically excludes the directory from the
    published tarball.
  • New src/proto/generated/sketchlib.v1.rs — the vendored prost output
    (652 lines).
  • Modified src/proto.rsinclude! 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 on
    the wrapping pub mod sketchlib.
  • Modified Cargo.toml — removed [build-dependencies], added an
    explanatory comment.
  • Modified Cargo.lock — ~280 lines (~30 transitive crates) dropped.
  • Modified .github/workflows/ci.yml — added the
    proto-vendored-up-to-date job.
  • Modified .github/workflows/docs.ymlpaths filter swaps
    build.rs for tools/gen-proto/**.
  • Updated README.md and docs/library_map.md to describe the new
    generation workflow.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --all-features --locked (including the
    cross_language_proto roundtrip test that validates wire-format
    compatibility with sketchlib-go)
  • RUSTDOCFLAGS=-D warnings cargo doc --no-deps --all-features --locked
  • cargo package --list --allow-dirty confirms tools/gen-proto/ is
    not shipped to crates.io and src/proto/generated/sketchlib.v1.rs is.
  • cargo metadata --no-deps confirms tools/gen-proto is not a
    member of the asap_sketchlib workspace.
  • CI green on PR — including the new drift-protection job.

Made with Cursor

GordonYuanyc and others added 2 commits May 14, 2026 07:26
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>
@GordonYuanyc GordonYuanyc merged commit 4aeb43c into main May 14, 2026
3 checks passed
@GordonYuanyc GordonYuanyc deleted the vendor-proto-codegen branch May 14, 2026 07:44
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.

1 participant