···2323 (static
2424 (flags
2525 (:standard -cclib -static -cclib -no-pie))))
2626+2727+;; Generate a small OCaml module `version.ml` at build time containing:
2828+;; let version = "<git-describe-or-fallback>"
2929+;; The command prefers an explicitly-provided GIT_DESCRIBE environment variable
3030+;; (useful in CI), otherwise falls back to `git describe`. If neither is
3131+;; available, it writes "unknown". This uses only shell builtins and common
3232+;; utilities (no python required).
3333+(rule
3434+ (targets version.ml)
3535+ (action
3636+ (with-stdout-to version.ml
3737+ (run sh -c
3838+ "v=${GIT_DESCRIBE:-$(git describe --tags --always --dirty 2>/dev/null || echo unknown)};
3939+ esc=$(printf '%s' \"$v\" | sed 's/\\\\/\\\\\\\\/g; s/\"/\\\\\\\"/g');
4040+ printf 'let version = \"%s\"\\n' \"$esc\""
4141+ ))))
+10
jj_tui/bin/main.ml
···55open Picos_std_structured
66open Jj_tui.Logging
77let () =
88+ (* Handle --version / -v early. A module `Version` is expected to be
99+ available (provided by `version.ml`, generated at build-time or present
1010+ as a fallback). It should expose `val version : string`. Use
1111+ `Version.version` here so the code refers to that module explicitly. *)
1212+ if Array.length Sys.argv > 1 then
1313+ match Sys.argv.(1) with
1414+ | "--version" | "-v" ->
1515+ print_endline Version.version;
1616+ exit 0
1717+ | _ -> ();
818 Ui.global_config.border_style<-Nottui.Ui.Border.unicode_rounded;
919 Ui.global_config.border_style_focused<-Nottui.Ui.Border.unicode_rounded;
1020 (* Ui.global_config.border_attr<-A.empty; *)