Skip to content

build(solana,sui): auto-generate presets/mod.rs from filesystem to eliminate per-PR conflicts#278

Merged
prasanna-anchorage merged 1 commit into
mainfrom
prasanna/build-rs-autogen-mod-rs
May 14, 2026
Merged

build(solana,sui): auto-generate presets/mod.rs from filesystem to eliminate per-PR conflicts#278
prasanna-anchorage merged 1 commit into
mainfrom
prasanna/build-rs-autogen-mod-rs

Conversation

@prasanna-anchorage
Copy link
Copy Markdown
Contributor

Why this PR exists

Every PR that adds a preset to visualsign-solana (and visualsign-sui) edits src/chain_parsers/visualsign-{solana,sui}/src/presets/mod.rs to add a single pub mod <name>; line at the alphabetically-correct position. Two preset PRs whose names land in adjacent slots collide on the same hunk during rebase.

This just bit us on the Kyle PR rebase batch:

What changed

Extends each crate's build.rs to also emit OUT_DIR/generated_presets_mod.rs (and the integrations equivalent), containing one #[path = "<abs>/mod.rs"] pub mod <name>; per subdirectory, sorted alphabetically. The hand-edited presets/mod.rs becomes a single-line include!(concat!(env!("OUT_DIR"), ...)) stub plus a doc header saying "do not edit". Adding a new preset is now a directory drop-in — no mod.rs edit, no conflict surface.

The #[path] attributes are required: include! makes Rust resolve pub mod declarations relative to the included file (OUT_DIR), not the file invoking include!. Absolute paths derived from CARGO_MANIFEST_DIR keep the generated file build-portable across machines and CI.

Both build.rs files are now Result-returning (fn main() -> BuildResult<()>) with ?/ok_or_else propagation throughout — no unwrap()/expect(), no #[allow(clippy::unwrap_used)] workspace-lint dodge.

Test plan

  • cargo build -p visualsign-solana and -p visualsign-sui succeed
  • cargo clippy --workspace --all-targets -- -D warnings is clean
  • cargo test --workspace --lib (369 tests) passes
  • cargo fmt --check is clean
  • Generated target/debug/build/visualsign-solana-*/out/generated_presets_mod.rs lists every preset directory sorted alphabetically with absolute #[path]

Knock-on for in-flight PRs

Open Kyle preset PRs (#256, #257, #258, #261, #263, #264, #265, #266, #267, #269, #270, #276) will need one more rebase after this lands; the presets/mod.rs conflict on each resolves to dropping the PR's pub mod <name>; line entirely. After that, no more rebase conflicts on this file ever.

Why draft

So you can review the build.rs rewrite (Result-propagating + #[path] mechanism) before promoting / merging.

🤖 Generated with Claude Code

@prasanna-anchorage prasanna-anchorage requested a review from r-n-o May 5, 2026 11:13
@prasanna-anchorage prasanna-anchorage marked this pull request as ready for review May 5, 2026 11:13
Copilot AI review requested due to automatic review settings May 5, 2026 11:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 moves the Solana and Sui parser crates from hand-maintained presets/mod.rs / integrations/mod.rs files to build-generated module declarations, reducing merge conflicts when new presets or integrations are added while keeping build-time visualizer discovery intact.

Changes:

  • Refactors both build.rs files to return Result, generate generated_presets_mod.rs / generated_integrations_mod.rs, and keep the existing generated visualizer registry flow.
  • Replaces hand-edited presets/mod.rs stubs in both crates with include!-based generated module declarations.
  • Replaces hand-edited integrations/mod.rs stubs in both crates with the same generated-module pattern.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/chain_parsers/visualsign-sui/src/presets/mod.rs Replaces manual Sui preset module list with generated include stub and guidance comments.
src/chain_parsers/visualsign-sui/src/integrations/mod.rs Replaces manual Sui integration module wiring with generated include stub.
src/chain_parsers/visualsign-sui/build.rs Adds generated module-declaration output alongside the existing generated visualizer list.
src/chain_parsers/visualsign-solana/src/presets/mod.rs Replaces manual Solana preset module list with generated include stub and guidance comments.
src/chain_parsers/visualsign-solana/src/integrations/mod.rs Replaces manual Solana integration module wiring with generated include stub.
src/chain_parsers/visualsign-solana/build.rs Refactors build script error handling and generates module declarations for presets/integrations.

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

pepe-anchor
pepe-anchor previously approved these changes May 13, 2026
`src/chain_parsers/visualsign-{solana,sui}/src/presets/mod.rs` was a
hand-edited list of `pub mod <name>;` lines, one per preset. Every PR
that added a preset edited this file at the alphabetically-correct
position, so any two preset PRs whose names landed in adjacent slots
collided on the same hunk during rebase.

This bit us on the most recent Kyle PR rebase batch — PRs #256
(jupiter_earn) and #263 (jupiter_borrow) both conflicted with main's
newly merged dflow_aggregator entry and required hand resolution. With
13 open preset PRs in flight, the conflict cost compounds.

Fix: extend each crate's `build.rs` to also emit
`OUT_DIR/generated_presets_mod.rs` (and the integrations equivalent)
containing `#[path = "<abs>/mod.rs"] pub mod <name>;` per subdirectory,
sorted alphabetically. The hand-edited `presets/mod.rs` becomes a
single-line `include!(concat!(env!("OUT_DIR"), "/generated_presets_mod.rs"))`
stub plus a doc header that says "do not edit". Adding a new preset is
now a directory drop-in — no `mod.rs` edit, no conflict surface.

The `#[path]` attributes are required because `include!` causes Rust to
resolve `pub mod` declarations relative to the included file's location
(OUT_DIR), not the file invoking `include!`. Absolute paths via
CARGO_MANIFEST_DIR keep the generated file build-portable.

Build scripts are now Result-returning (`fn main() -> BuildResult<()>`)
with `?`/`ok_or_else` propagation throughout — no `unwrap()`/`expect()`,
no `#[allow(clippy::unwrap_used)]` workspace-lint dodge.

Verification:
- `cargo build -p visualsign-solana` and `-p visualsign-sui` succeed.
- `cargo clippy --workspace --all-targets -- -D warnings` clean.
- `cargo test --workspace --lib` passes (all 369 library tests).
- `cargo fmt --check` clean.
- Generated content (sample): visualsign-solana writes 9 entries, one
  per preset directory, sorted alphabetically.

Knock-on: open Kyle PRs will conflict on `presets/mod.rs` one last
time when rebasing onto this — resolution is to drop the PR's
`pub mod <name>;` line entirely. Future preset PRs need zero edits to
this file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@prasanna-anchorage prasanna-anchorage force-pushed the prasanna/build-rs-autogen-mod-rs branch from 05bf317 to ecd947e Compare May 13, 2026 20:36
@prasanna-anchorage prasanna-anchorage enabled auto-merge (squash) May 13, 2026 23:11
@prasanna-anchorage prasanna-anchorage merged commit 06ec9a5 into main May 14, 2026
9 checks passed
@prasanna-anchorage prasanna-anchorage deleted the prasanna/build-rs-autogen-mod-rs branch May 14, 2026 14:30
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.

3 participants