2007-02-07 00:59:16 -08:00
|
|
|
(***********************************************************************)
|
2012-08-01 07:47:00 -07:00
|
|
|
(* *)
|
2007-02-07 00:59:16 -08:00
|
|
|
(* 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 *)
|
2015-07-28 06:18:34 -07:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
2007-02-07 00:59:16 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2009-03-03 08:54:58 -08:00
|
|
|
|
2007-02-07 00:59:16 -08:00
|
|
|
(* Original author: Berke Durak *)
|
|
|
|
(* FDA *)
|
|
|
|
|
|
|
|
open Log
|
|
|
|
open Hygiene
|
|
|
|
;;
|
|
|
|
|
|
|
|
exception Exit_hygiene_failed
|
|
|
|
;;
|
|
|
|
|
|
|
|
let laws =
|
|
|
|
[
|
2012-02-13 09:48:41 -08:00
|
|
|
{ law_name = "Leftover OCaml compilation files";
|
2007-02-07 00:59:16 -08:00
|
|
|
law_rules = [Not ".cmo"; Not ".cmi"; Not ".cmx"; Not ".cma"; Not ".cmxa"];
|
|
|
|
law_penalty = Fail };
|
2012-02-13 09:48:41 -08:00
|
|
|
{ law_name = "Leftover OCaml type annotation files";
|
2007-02-07 00:59:16 -08:00
|
|
|
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
|
2007-02-08 08:53:39 -08:00
|
|
|
match Hygiene.check
|
2007-02-22 07:56:23 -08:00
|
|
|
?sanitize:
|
2007-02-08 08:53:39 -08:00
|
|
|
begin
|
2007-02-22 07:56:23 -08:00
|
|
|
if !Options.sanitize then
|
2007-11-22 10:29:32 -08:00
|
|
|
Some(Pathname.concat !Options.build_dir !Options.sanitization_script)
|
2007-02-08 08:53:39 -08:00
|
|
|
else
|
|
|
|
None
|
|
|
|
end
|
|
|
|
laws entry
|
|
|
|
with
|
|
|
|
| [] -> ()
|
|
|
|
| stuff ->
|
2007-02-07 00:59:16 -08:00
|
|
|
List.iter
|
|
|
|
begin fun (law, msgs) ->
|
|
|
|
Printf.printf "%s: %s:\n"
|
|
|
|
(match law.law_penalty with
|
|
|
|
| Warn -> "Warning"
|
|
|
|
| Fail ->
|
|
|
|
if not !evil then
|
|
|
|
begin
|
2007-02-08 08:53:39 -08:00
|
|
|
Printf.printf "IMPORTANT: I cannot work with leftover compiled files.\n%!";
|
2007-02-07 00:59:16 -08:00
|
|
|
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;
|
|
|
|
;;
|