mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
7b25a42970
Always generate the version through git when possible, and encode that within the binaries so that `catala --version` does'nt give misleading information. Previously we used dune's builtin functionality, but that resorts to a hack at install time which is unpleasant and doesn't work with our use of `opam install`. The cost is a re-linking of catala_utils and the binaries upon git commit, which is hardly noticeable.
18 lines
642 B
OCaml
18 lines
642 B
OCaml
(** This trivial binary is run at build-time to get the correct version from the
|
|
build environment (either the CATALA_VERSION) environment variable if
|
|
defined, or `git describe`, or resorting to just "dev" if none of these can
|
|
be found *)
|
|
|
|
let v =
|
|
match Sys.getenv_opt "CATALA_VERSION" with
|
|
| None | Some "" -> (
|
|
let ic = Unix.open_process_in "git describe --tags --dirty 2>/dev/null" in
|
|
let v = try input_line ic with _ -> "dev" in
|
|
match Unix.close_process_in ic with Unix.WEXITED 0 -> v | _ -> "dev")
|
|
| Some v -> v
|
|
|
|
let () =
|
|
print_string "let v = \"";
|
|
print_string (String.escaped v);
|
|
print_endline "\""
|