@@ -47,7 +47,20 @@ pub fn tabs(n int) string {
47
47
return if n > = 0 && n < const_tabs.len { const_tabs[n] } else { '\t ' .repeat (n) }
48
48
}
49
49
50
- //
50
+ // get_build_time returns the current build time, while taking into account SOURCE_DATE_EPOCH
51
+ // to support transparent reproducible builds. See also https://reproducible-builds.org/docs/source-date-epoch/
52
+ // When SOURCE_DATE_EPOCH is not set, it will return the current UTC time.
53
+ pub fn get_build_time () time.Time {
54
+ sde := os.getenv ('SOURCE_DATE_EPOCH' )
55
+ if sde == '' {
56
+ return time.utc ()
57
+ }
58
+ return time.unix_nanosecond (sde.i64 (), 0 )
59
+ }
60
+
61
+ // set_vroot_folder sets the VCHILD env variable to 'true', and VEXE to the location of the V executable
62
+ // It is called very early by launch_tool/3, so that those env variables can be available by all tools,
63
+ // like `v doc`, `v fmt` etc, so they can use them to find how they were started.
51
64
pub fn set_vroot_folder (vroot_path string ) {
52
65
// Preparation for the compiler module:
53
66
// VEXE env variable is needed so that compiler.vexe_path() can return it
@@ -61,6 +74,8 @@ pub fn set_vroot_folder(vroot_path string) {
61
74
os.setenv ('VCHILD' , 'true' , true )
62
75
}
63
76
77
+ // resolve_vmodroot replaces all occurences of `@VMODROOT` in `str`, with an absolute path,
78
+ // formed by resolving, where the nearest `v.mod` is, given the folder `dir`.
64
79
pub fn resolve_vmodroot (str string , dir string ) ! string {
65
80
mut mcache := vmod.get_cache ()
66
81
vmod_file_location := mcache.get_by_folder (dir)
0 commit comments