Skip to main content

derive_output_path

Function derive_output_path 

Source
pub fn derive_output_path(source_path: &Path, target: &TargetProfile) -> PathBuf
Expand description

Derive the output path for a generated file from its source .bock path.

Per spec §20.6.1, a source file at src/<path>.bock produces output at <path>.<ext> (relative to the target build directory). Sources outside src/ keep their full path. The returned PathBuf is always relative — callers prepend build/<target>/.

  • src/main.bockmain.<ext>
  • src/utils/parse.bockutils/parse.<ext>
  • main.bockmain.<ext> (no src/ prefix to strip)

Leading ./ and any other curdir components are normalized away before stripping, so the source path can be supplied either bare or with a ./ prefix as produced by directory traversal.