Commit c779983f authored by Stephane Glondu's avatar Stephane Glondu

Add "debug" variable to Belenios_version, move it to platform

parent 0795a6f8
((nil . ((eval . (setq compile-command (format "cd %s && make all" (locate-dominating-file buffer-file-name ".dir-locals.el")))))))
((nil . ((eval . (setq compile-command (format "cd %s && BELENIOS_DEBUG=1 make all" (locate-dominating-file buffer-file-name ".dir-locals.el")))))))
open Ocamlbuild_plugin
let debug =
try Sys.getenv "BELENIOS_DEBUG" <> ""
with Not_found -> false
let try_exec cmd =
Sys.command (cmd ^ " >/dev/null 2>&1") = 0
......@@ -32,7 +36,9 @@ let platform_rules kind =
rule mllib ~deps:[ml] ~prods:[mllib] (fun _ _ ->
(* technically, there is no dependency, but we need the directory to
exist for the following *)
Echo ([platform_dir / kind / "Platform"; "\n"], mllib)
Echo ([platform_dir / kind / "Belenios_version"; "\n";
platform_dir / kind / "Platform"; "\n"],
mllib)
);
dep ["file:" ^ ml] [mli];
copy_rule mli (lib / "platform.mli") mli;
......@@ -47,10 +53,10 @@ let build_rule () =
in
rule "BUILD" ~deps ~prod builder
let version_rule () =
let version_rules kind =
let file = "BUILD" in
let deps = [file; "src/lib/belenios_version.mli"] in
let prod = "src/lib/belenios_version.ml" in
let deps = [file; "src/platform/" ^ kind ^ "/belenios_version.mli"] in
let prod = "src/platform/" ^ kind ^ "/belenios_version.ml" in
let builder _ _ =
let version, build =
let ic = open_in file in
......@@ -62,10 +68,15 @@ let version_rule () =
let lines = Printf.([
sprintf "let version = \"%s\"" version;
sprintf "let build = \"%s\"" build;
sprintf "let debug = %b" debug;
]) in
Echo (lines, prod)
in
rule "BUILD -> belenios_version.ml" ~deps ~prod builder
copy_rule
(kind / "belenios_tool.mli")
"src/lib/belenios_version.mli"
("src/platform/" ^ kind ^ "/belenios_version.mli");
rule ("BUILD -> " ^ kind ^ "/belenios_version.ml") ~deps ~prod builder
let copy_static f =
let base = Filename.basename f in
......@@ -103,7 +114,8 @@ let () = dispatch & function
);
build_rule ();
version_rule ();
version_rules "native";
version_rules "js";
platform_rules "native";
platform_rules "js";
......
val version : string
val build : string
val debug : bool
......@@ -468,7 +468,9 @@ end
let cmds = Tkeygen.cmds @ Election.cmds @ Credgen.cmds @ Mkelection.cmds @ Verifydiff.cmds
let default_cmd =
let version = Belenios_version.(Printf.sprintf "%s (%s)" version build) in
let open Belenios_version in
let version = Printf.sprintf "%s (%s)" version build in
let version = if debug then version ^ " [debug]" else version in
let doc = "election management tool" in
let man = common_man in
Term.(ret (pure (`Help (`Pager, None)))),
......
src/platform/native/Belenios_version
src/platform/native/Platform
Serializable_builtin_t
Serializable_builtin_j
......
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