Skip to content

Commit e9c2314

Browse files
committed
pref: add Preferences.vroot_file/1 (done here, without using it, to ease the bootstrapping of the cheaders extraction, that will follow next)
1 parent 025e703 commit e9c2314

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎vlib/v/pref/default.v‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,11 @@ pub fn (p &Preferences) vcross_compiler_name() string {
377377
}
378378
return 'cc'
379379
}
380+
381+
// vroot_file reads the given file, given a path relative to @VROOT .
382+
// Its goal is to give all backends a shared infrastructure to read their own static preludes (like C headers etc),
383+
// without each having to implement their own way of lookup/embedding/caching them.
384+
pub fn (mut p Preferences) vroot_file(path string) string {
385+
full_path := os.join_path(p.vroot, path)
386+
return os.read_file(full_path) or { '/* missing vroot content of path: ${full_path} */' }
387+
}

0 commit comments

Comments
 (0)