@@ -44,6 +44,9 @@ module P = Process
4444(* Note: don't open [Process], otherwise any reference to [Output] will be
4545 * understood as a cyclic dependency on our own [Output] module. *)
4646
47+ (* TODO: raise this further? *)
48+ let git_rev_length = 10
49+
4750(* * These three variables filled in by [detect_fstar] *)
4851let fstar = ref " "
4952let fstar_home = ref " "
@@ -181,7 +184,7 @@ let detect_karamel () =
181184 if try Sys. is_directory (krml_home ^^ " .git" ) with Sys_error _ -> false then begin
182185 let cwd = Sys. getcwd () in
183186 Sys. chdir krml_home;
184- krml_rev := String. sub (read_one_line " git" [| " rev-parse" ; " HEAD" |]) 0 8 ;
187+ krml_rev := String. sub (read_one_line " git" [| " rev-parse" ; " HEAD" |]) 0 git_rev_length ;
185188 Sys. chdir cwd
186189 end ;
187190
@@ -250,16 +253,12 @@ let detect_fstar () =
250253 KPrint. bprintf " %sfstar lib converted to windows path:%s %s\n " Ansi. underline Ansi. reset ! fstar_lib
251254 end ;
252255
253- if try Sys. is_directory (! fstar_home ^^ " .git" ) with Sys_error _ -> false then begin
254- let cwd = Sys. getcwd () in
255- Sys. chdir ! fstar_home;
256- let branch = read_one_line " git" [| " rev-parse" ; " --abbrev-ref" ; " HEAD" |] in
257- fstar_rev := String. sub (read_one_line " git" [| " rev-parse" ; " HEAD" |]) 0 8 ;
258- let color = if branch = " master" then Ansi. green else Ansi. orange in
259- if not ! Options. silent then
260- KPrint. bprintf " fstar is on %sbranch %s%s\n " color branch Ansi. reset;
261- Sys. chdir cwd
262- end ;
256+ (* As fstar.exe path is known, use fstar.exe --version flag *)
257+ let fstar_version_output = Process. read_stdout ! fstar [| " --version" |] in
258+ (* fstar.exe --version currently yields a few lines,
259+ fifth line is of the form commit=<git revision> *)
260+ let fstar_rev_full = List. nth fstar_version_output 4 in
261+ fstar_rev := String. sub fstar_rev_full (String. length " commit=" ) git_rev_length;
263262
264263 let fstar_includes = List. map expand_prefixes ! Options. includes in
265264 fstar_options := [
0 commit comments