Skip to main content

Module shim_paths

Module shim_paths 

Source
Expand description

Resolve the on-disk paths of whisker-rustc-shim and whisker-linker-shim for the dev session.

Both shims are [[bin]] targets of the whisker-cli package, shipped alongside the main whisker binary. The dev-server needs absolute paths to set them as RUSTC_WORKSPACE_WRAPPER and -C linker=….

Resolution order:

  1. Beside the running whisker binary (current_exe()’s dir). cargo install whisker-cli installs all three bins into ~/.cargo/bin together, so external (crates.io) users resolve here and never need an in-workspace build. In-workspace dev also matches once the shims are built (they sit next to target/debug/whisker).
  2. <target>/debug/CARGO_TARGET_DIR env wins, else <workspace>/target. Covers an in-workspace run whose current_exe lives elsewhere (e.g. invoked via a wrapper).
  3. Build them with cargo build -p whisker-cli --bin … from the workspace, then re-check. Only meaningful in-workspace (where whisker-cli is a member); for external users step 1 already succeeded. A build failure surfaces as Err(_) and the caller falls back to Tier 2.

Structs§

ShimPaths
Absolute paths to both shim binaries.

Functions§

exe_name
Pure helper: append .exe on Windows. Pulled out so tests don’t have to fork on cfg.
expected_shim_paths
Compute the expected shim paths without touching the filesystem. Pure function — used both in tests and as the first half of resolve_shim_paths.
resolve_shim_paths
Resolve both shim paths. Build them with cargo build if the binaries aren’t on disk yet. Returns absolute paths suitable for passing to RUSTC_WORKSPACE_WRAPPER and -C linker=….
shim_paths_in_dir
The two shim paths as they’d sit inside dir. Pure — used both for the current_exe() neighbor lookup and in tests.