forked from abella-prover/abella
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyocamlbuild.ml
68 lines (61 loc) · 2.24 KB
/
myocamlbuild.ml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(* See LICENSE for licensing details. *)
(* BEGIN VERSION *)
let major_version : int = 2
let minor_version : int = 0
let patch_version : int = 8
let flavor_version : string option = Some "dev"
(* END VERSION *)
let version_string =
Printf.sprintf "%d.%d.%d%s" major_version minor_version patch_version
(match flavor_version with
| Some v -> "-" ^ v
| None -> "")
let version_file_contents =
let buf = Buffer.create 255 in
let printf fmt = Printf.bprintf buf (fmt ^^ "\n") in
printf "(* DO NOT EDIT *)" ;
printf "(* this file is automatically generated by myocamlbuild.ml *)" ;
printf "let major : int = %d;;" major_version ;
printf "let minor : int = %d;;" minor_version ;
printf "let patch : int = %d;;" patch_version ;
printf "let flavor : string option = %s;;" begin
match flavor_version with
| None -> "None"
| Some v -> "Some \"" ^ String.escaped v ^ "\""
end ;
printf "let version = %S;;" version_string ;
printf "let self_digest = Digest.file Sys.executable_name;;" ;
Buffer.contents buf
let version_file = "src/version.ml"
let maybe_make_version_file () =
if not begin
Sys.file_exists version_file
&& Digest.file version_file = Digest.string version_file_contents
end then begin
Printf.printf "Recreating %S\n" version_file ;
let oc = open_out version_file in
output_string oc version_file_contents ;
close_out oc
end
open Ocamlbuild_plugin ;;
let () =
maybe_make_version_file () ;
Options.use_ocamlfind := true ;
dispatch begin function
| After_rules ->
(* flag ["ocaml" ; "compile"] (A "-g") ; *)
(* flag ["ocaml" ; "link"] (A "-g") ; *)
Scanf.sscanf Sys.ocaml_version "%d.%d."
(fun major minor ->
if major >= 4 then begin
flag ["ocaml" ; "compile"] (A "-bin-annot") ;
if minor >= 2 && minor < 6 then
flag ["ocaml" ; "compile"] (A "-safe-string") ;
if minor >= 6 then
flag ["ocaml" ; "compile"] (A "-strict-formats") ;
end) ;
if Sys.os_type = "Unix" then
flag ["ocaml" ; "compile"] (S [A "-w" ; A "@a-4-29-40-41-42-44-45-48-58-59-60"]) ;
flag ["ocaml" ; "native" ; "compile"] (A "-nodynlink") ;
| _ -> ()
end