Skip to content

refactor: split zig.rs into smaller modules - #470

Merged
messense merged 1 commit into
mainfrom
refactor-zig-module
Aug 27, 2026
Merged

refactor: split zig.rs into smaller modules#470
messense merged 1 commit into
mainfrom
refactor-zig-module

Conversation

@messense

Copy link
Copy Markdown
Member

What

Converts the 3000-line src/zig.rs into a src/zig/ directory split by concern. This is a pure move refactor — no behavior changes.

File Contents
mod.rs Zig clap subcommand + execution entry points (zig cc/ar/dlltool dispatch), re-exports
target_info.rs TargetInfo and its target-triple predicates
linker_args.rs linker arg filtering + CPU/feature name mapping, with the whole test_filter_* suite alongside
locate.rs finding/validating the zig toolchain (find_zig, zig_version, lib_dir, cache_dir)
cargo_env.rs cargo build env setup (apply_command_env, bindgen options, OS deps, cmake toolchain)
wrapper.rs linker wrapper script generation (prepare_zig_linker, TargetFlags, script quoting)

Compatibility

Public API is unchanged: zig::Zig, zig::ZigWrapper, zig::prepare_zig_linker, and zig::adjust_canonicalization resolve to the same paths via re-exports in mod.rs, so library consumers (e.g. maturin) are unaffected. Helpers that now cross file boundaries became pub(crate); nothing new is pub.

Verification

  • cargo build — clean
  • cargo test — 37 passed, 0 failed (all filter/wrapper tests moved with their modules)
  • cargo clippy --all-targets --all-features — only pre-existing warnings (in code copied verbatim)
  • cargo fmt --all — no reformatting needed

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tmb8F6fH8SvQ6KarnaJuxR

Convert the 3000-line src/zig.rs into a src/zig/ directory split by
concern, as a pure move with no behavior changes:

- mod.rs: the Zig clap subcommand and its execution entry points
  (zig cc/ar/dlltool dispatch), plus re-exports keeping every public
  path (zig::Zig, zig::ZigWrapper, zig::prepare_zig_linker,
  zig::adjust_canonicalization) unchanged for library consumers
- target_info.rs: TargetInfo and its target-triple predicates
- linker_args.rs: linker argument filtering and CPU/feature name
  mapping, with the whole test_filter_* suite alongside
- locate.rs: finding and validating the zig toolchain (find_zig,
  zig_version, lib_dir, cache_dir)
- cargo_env.rs: cargo build environment setup (apply_command_env,
  bindgen options, OS deps, cmake toolchain)
- wrapper.rs: linker wrapper script generation (prepare_zig_linker,
  TargetFlags, script quoting helpers)

Helpers that now cross file boundaries became pub(crate); nothing new
is pub.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tmb8F6fH8SvQ6KarnaJuxR
@messense
messense enabled auto-merge (squash) August 27, 2026 01:15
@messense
messense merged commit 52c51bd into main Aug 27, 2026
49 checks passed
@messense
messense deleted the refactor-zig-module branch August 27, 2026 01:37
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