diff --git a/lib/bap_main/bap_main.ml b/lib/bap_main/bap_main.ml index 2897591d0..aada1d044 100644 --- a/lib/bap_main/bap_main.ml +++ b/lib/bap_main/bap_main.ml @@ -1161,6 +1161,9 @@ let init List.partition_map result ~f:(function | Ok p -> `Fst p | Error (p,e) -> `Snd (p,e)) in + let version = match Bap_main_config.build_id with + | "" -> version + | id -> sprintf "%s+%s" version id in if List.is_empty failures then match Grammar.eval argv ?name ~version ?env ?help:out diff --git a/lib/bap_main/bap_main_config.ml.ab b/lib/bap_main/bap_main_config.ml.ab index edcbe19f2..88f9bd0cd 100644 --- a/lib/bap_main/bap_main_config.ml.ab +++ b/lib/bap_main/bap_main_config.ml.ab @@ -28,3 +28,4 @@ let suffix_program = "$suffix_program" let debug = "$debug" let profile = "$profile" let standard_library = "$standard_library" +let build_id = "$build_id" \ No newline at end of file diff --git a/oasis/main.setup.ml.in b/oasis/main.setup.ml.in new file mode 100644 index 000000000..9bfd9f8c1 --- /dev/null +++ b/oasis/main.setup.ml.in @@ -0,0 +1,14 @@ + +let () = + add_variable "build_id" + ~doc:"Adds a build id to bap version" + ~define:(function + | Some x -> x + | None -> + try + if Sys.file_exists ".git" && Sys.is_directory ".git" then + OASISExec.run_read_one_line ~ctxt + ~f_exit_code:ignore + "git" ["rev-parse"; "--verify"; "--quiet"; "--short=7"; "HEAD"; ] + else "" + with _ -> "")