Skip to content

Commit

Permalink
pref: add Preferences.vroot_file/1 (done here, without using it, to e…
Browse files Browse the repository at this point in the history
…ase the bootstrapping of the cheaders extraction, that will follow next)
  • Loading branch information
spytheman committed Feb 13, 2025
1 parent 025e703 commit e9c2314
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vlib/v/pref/default.v
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,11 @@ pub fn (p &Preferences) vcross_compiler_name() string {
}
return 'cc'
}

// vroot_file reads the given file, given a path relative to @VROOT .
// Its goal is to give all backends a shared infrastructure to read their own static preludes (like C headers etc),
// without each having to implement their own way of lookup/embedding/caching them.
pub fn (mut p Preferences) vroot_file(path string) string {
full_path := os.join_path(p.vroot, path)
return os.read_file(full_path) or { '/* missing vroot content of path: ${full_path} */' }
}

0 comments on commit e9c2314

Please sign in to comment.