Skip to content

Commit

Permalink
Fix Nix build header: F* rev empty
Browse files Browse the repository at this point in the history
use fstar.exe --version instead of
git rev-parse HEAD in /home/build/setup/FStar directory;
bump git revision length from 8 to 12
  • Loading branch information
Antonin Reitz committed Oct 27, 2023
1 parent 7460546 commit f198096
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/Driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ let detect_karamel () =
if try Sys.is_directory (krml_home ^^ ".git") with Sys_error _ -> false then begin
let cwd = Sys.getcwd () in
Sys.chdir krml_home;
krml_rev := String.sub (read_one_line "git" [| "rev-parse"; "HEAD" |]) 0 8;
krml_rev := String.sub (read_one_line "git" [| "rev-parse"; "HEAD" |]) 0 12;
Sys.chdir cwd
end;

Expand Down Expand Up @@ -250,16 +250,13 @@ let detect_fstar () =
KPrint.bprintf "%sfstar lib converted to windows path:%s %s\n" Ansi.underline Ansi.reset !fstar_lib
end;

if try Sys.is_directory (!fstar_home ^^ ".git") with Sys_error _ -> false then begin
let cwd = Sys.getcwd () in
Sys.chdir !fstar_home;
let branch = read_one_line "git" [| "rev-parse"; "--abbrev-ref"; "HEAD" |] in
fstar_rev := String.sub (read_one_line "git" [| "rev-parse"; "HEAD" |]) 0 8;
let color = if branch = "master" then Ansi.green else Ansi.orange in
if not !Options.silent then
KPrint.bprintf "fstar is on %sbranch %s%s\n" color branch Ansi.reset;
Sys.chdir cwd
end;
(* As fstar.exe path is known, use fstar.exe --version flag *)
let fstar_version_output = Process.read_stdout !fstar [| "--version" |] in
(* fstar.exe --version currently yields a few lines,
one is of the form commit=<git revision> *)
fstar_rev := List.hd (KList.filter_map
(fun s -> if KString.starts_with s "commit=" then Some (String.sub s (String.length "commit=") 12) else None)
fstar_version_output);

let fstar_includes = List.map expand_prefixes !Options.includes in
fstar_options := [
Expand Down

0 comments on commit f198096

Please sign in to comment.