-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
dune
50 lines (43 loc) · 1.05 KB
/
dune
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(* -*- tuareg -*- *)
open StdLabels
open Jbuild_plugin.V1
let split_on_char ~sep s =
let r = ref [] in
let j = ref (String.length s) in
for i = String.length s - 1 downto 0 do
if String.unsafe_get s i = sep
then (
r := String.sub s ~pos:(i + 1) ~len:(!j - i - 1) :: !r;
j := i )
done;
String.sub s ~pos:0 ~len:!j :: !r
let git_version =
if not (try Sys.is_directory ".git" with _ -> false)
then ""
else
match run_and_read_lines "git log -n1 --pretty=format:%h" with
| version :: _ -> version
| [] -> ""
let version =
let ic = open_in "VERSION" in
let version = input_line ic in
close_in ic; version
let extra_warnings =
let v = split_on_char ~sep:'.' ocaml_version in
if v < ["4"; "03"] then "-45" else ""
let () =
send
@@ Printf.sprintf
{|
(env
(dev
(flags
(:standard -w +a-4-40-41-42-44-48-58-66%s))))
(rule
(targets version.ml.in)
(action (with-stdout-to %%{targets}
(echo "let s = \"%s\"\nlet git_version = \"%s\""))))
|}
extra_warnings
version
git_version