forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfda.ml
83 lines (77 loc) · 2.74 KB
/
fda.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(***********************************************************************)
(* *)
(* ocamlbuild *)
(* *)
(* Nicolas Pouillard, Berke Durak, projet Gallium, INRIA Rocquencourt *)
(* *)
(* Copyright 2007 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Library General Public License, with *)
(* the special exception on linking described in file ../LICENSE. *)
(* *)
(***********************************************************************)
(* Original author: Berke Durak *)
(* FDA *)
open Log
open Hygiene
;;
exception Exit_hygiene_failed
;;
let laws =
[
{ law_name = "Leftover OCaml compilation files";
law_rules = [Not ".cmo"; Not ".cmi"; Not ".cmx"; Not ".cma"; Not ".cmxa"];
law_penalty = Fail };
{ law_name = "Leftover OCaml type annotation files";
law_rules = [Not ".annot"];
law_penalty = Warn };
{ law_name = "Leftover object files";
law_rules = [Not ".o"; Not ".a"; Not ".so"; Not ".obj"; Not ".lib"; Not ".dll"];
law_penalty = Fail };
{ law_name = "Leftover ocamlyacc-generated files";
law_rules = [Implies_not(".mly",".ml"); Implies_not(".mly",".mli")];
law_penalty = Fail };
{ law_name = "Leftover ocamllex-generated files";
law_rules = [Implies_not(".mll",".ml")];
law_penalty = Fail };
{ law_name = "Leftover dependency files";
law_rules = [Not ".ml.depends"; Not ".mli.depends"];
law_penalty = Fail }
]
let inspect entry =
dprintf 5 "Doing sanity checks";
let evil = ref false in
match Hygiene.check
?sanitize:
begin
if !Options.sanitize then
Some(Pathname.concat !Options.build_dir !Options.sanitization_script)
else
None
end
laws entry
with
| [] -> ()
| stuff ->
List.iter
begin fun (law, msgs) ->
Printf.printf "%s: %s:\n"
(match law.law_penalty with
| Warn -> "Warning"
| Fail ->
if not !evil then
begin
Printf.printf "IMPORTANT: I cannot work with leftover compiled files.\n%!";
evil := true
end;
"ERROR")
law.law_name;
List.iter
begin fun msg ->
Printf.printf " %s\n" msg
end
msgs
end
stuff;
if !evil then raise Exit_hygiene_failed;
;;