(** This module gives access to the same version/build information returned by
    [Command]-based executables when called with the [-version] or [-build-info] flags
    by [$0 version (-build-info | -version)] or [$0 (-build-info | -version)].

    Here's how it works: we arrange for the build system to, at link time, include an
    object file that defines symbols that version_util.ml uses to get the strings that
    contain the information that this module provides.  When building with OMake, our
    OMakeroot runs build_info.sh to generate *.build_info.c with the symbols and that is
    linked in.
*)

open! Core_kernel

val version_list : string list (** All hg repos and their revision. *)

(** Like [version_list] but space separated. Consider using [version_list] instead. *)
val version : string

(** [Version] may be used to parse a single entry from [version_list]. *)
module Version : sig
  type t =
    { repo : string
    ; version : string
    } [@@deriving sexp_of]

  val parse : string -> t Or_error.t
end

val arg_spec : (string * Arg.spec * string) list

(** [Application_specific_fields] is a single field in the build-info sexp that holds
    a [Sexp.t String.Map.t], which can be chosen by the application to hold custom
    fields that it needs. *)
module Application_specific_fields : sig
  type t = Sexp.t String.Map.t [@@deriving sexp]
end

(** Various additional information about the circumstances of the build: who built it,
    when, on what machine, etc.
    [build_info] is the information as it was generated by the build system.
    [reprint_build_info] parses and prints the string back, which alters a bit the layout
    and order of the fields but more importantly allows to display times in the current
    zone. *)
val build_info : string
val build_info_as_sexp : Sexp.t
val reprint_build_info : (Time.t -> Sexp.t) -> string

val username                       : string option
val hostname                       : string option
val kernel                         : string option
val build_time                     : Time.t option
val x_library_inlining             : bool
val portable_int63                 : bool
val dynlinkable_code               : bool
val compiled_for_speed             : bool
val application_specific_fields    : Application_specific_fields.t option
val ocaml_version                  : string
val allowed_projections            : string list option

val executable_path                : string (** Relative to OMakeroot dir *)

val build_system                   : string
val with_fdo                       : (string * Md5.t option) option

module For_tests : sig
  val parse_generated_hg_version : string -> string list
end
