aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChimrod <>2023-10-01 19:30:58 +0200
committerChimrod <>2023-10-01 19:30:58 +0200
commitb7964befd039c41c63e00ef323f9eb49061c144c (patch)
treeed2eb4eeaf60cbc2ed560931203fb1a2fcf682ef
parent622bbf897af29ec6f7d533f915b0170d3a9c899f (diff)
Added the git revision in the code
-rw-r--r--bin/dune4
-rw-r--r--bin/qsp_parser.ml10
-rw-r--r--tools/dune10
-rwxr-xr-xtools/git_head.sh9
4 files changed, 30 insertions, 3 deletions
diff --git a/bin/dune b/bin/dune
index f7aacc3..58e96ff 100644
--- a/bin/dune
+++ b/bin/dune
@@ -4,7 +4,9 @@
(libraries
sedlex
qsp_syntax
- qparser)
+ qparser
+ tools
+ )
(preprocess (pps
ppx_deriving.show
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index fb0c1c8..32e7a2f 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -21,6 +21,12 @@ module Args = struct
let speclist =
[
+ ( "--version",
+ Arg.Unit
+ (fun () ->
+ Printf.printf "Version %s\n" Tools.Git_hash.revision;
+ exit 0),
+ "Display the version of the application and exit" );
("--level", Arg.String level, "Message level [debug, warn, error]");
( "--global",
Arg.Set reset_line,
@@ -64,12 +70,12 @@ let parse_location : Qparser.Lexbuf.t -> filters -> unit =
| [] -> ()
| _ ->
let start_position, _ = Qparser.Lexbuf.positions lexbuf in
- Format.fprintf Format.std_formatter "Location %s@;@[%a@]@."
+ Format.fprintf Format.std_formatter "Location@ %s@;@[%a@]@."
start_position.Lexing.pos_fname pp_result report;
())
| Error e ->
let start_position, _ = Qparser.Lexbuf.positions lexbuf in
- Format.fprintf Format.std_formatter "Location %s@;@[%a]@."
+ Format.fprintf Format.std_formatter "Location@ %s@;@[%a]@."
start_position.Lexing.pos_fname Report.pp e
let () =
diff --git a/tools/dune b/tools/dune
new file mode 100644
index 0000000..2e223d4
--- /dev/null
+++ b/tools/dune
@@ -0,0 +1,10 @@
+(library
+ (name tools))
+
+(rule
+ (target git_hash.ml)
+ (deps git_head.sh)
+ (action
+ (with-stdout-to
+ %{target}
+ (bash "./git_head.sh"))))
diff --git a/tools/git_head.sh b/tools/git_head.sh
new file mode 100755
index 0000000..42c6dcb
--- /dev/null
+++ b/tools/git_head.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+# Include the git hash in an OCaml file.
+
+revision=$(git rev-parse --short HEAD)
+compile_date=$(date +%Y/%m/%d)
+
+
+echo "let revision = \"${revision} - compiled on ${compile_date}\""
+