(* -*- tuareg -*- *)
open StdLabels
open Jbuild_plugin.V1

let git_version =
  match run_and_read_lines "git describe --always --dirty" with
  | exception _ -> ""
  | version :: _ -> version
  | [] -> ""

let dyn =
  Printf.sprintf
    {|
(rule
  (target GIT-VERSION)
  (action (with-stdout-to %%{target} (echo "%s"))))
|}
    git_version

let () = send dyn
