Commit d9794ab0 authored by Stephane Glondu's avatar Stephane Glondu

Add Belenios_version

parent dce180af
#!/bin/sh
# the following is to be run from _build directory
if [ -d ../.git ] && which git >/dev/null 2>&1; then
BUILD=${BUILD:-$(git describe)}
else
BUILD=${BUILD:-$(date -u +%Y%m%d)}
fi
head -n1 VERSION
echo $BUILD
......@@ -38,6 +38,36 @@ let platform_rules kind =
copy_rule mli (lib / "platform.mli") mli;
ocaml_lib platform_lib
let build_rule () =
let genversion = "genversion.sh" in
let deps = ["VERSION"; genversion] in
let prod = "BUILD" in
let builder _ _ =
Cmd (S [A "sh"; P genversion; Sh ">"; P prod])
in
rule "BUILD" ~deps ~prod builder
let version_rule () =
let file = "BUILD" in
let deps = [file; "src/lib/belenios_version.mli"] in
let prod = "src/lib/belenios_version.ml" in
let builder _ _ =
let version, build =
let ic = open_in file in
let version = input_line ic in
let build = input_line ic in
close_in ic;
version, build
in
let lines = Printf.([
sprintf "let version = \"%s\"" version;
sprintf "let build = \"%s\"" build;
]) in
Echo (lines, prod)
in
rule "BUILD -> belenios_version.ml" ~deps ~prod builder
let () = dispatch & function
| Before_options ->
......@@ -68,6 +98,8 @@ let () = dispatch & function
Cmd (S [A"markdown"; P (env "%.md"); Sh">"; P (env "%.html")])
);
build_rule ();
version_rule ();
platform_rules "native";
platform_rules "js";
......
val version : string
val build : string
......@@ -416,10 +416,11 @@ end
let cmds = Tkeygen.cmds @ Election.cmds @ Credgen.cmds @ Mkelection.cmds
let default_cmd =
let version = Belenios_version.(Printf.sprintf "%s (%s)" version build) in
let doc = "election management tool" in
let man = common_man in
Term.(ret (pure (`Help (`Pager, None)))),
Term.info "belenios-tool" ~version:"0.2" ~doc ~man
Term.info "belenios-tool" ~version ~doc ~man
let () =
match Term.eval_choice default_cmd cmds with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment