diff options
author | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-11-28 16:02:14 +0000 |
---|---|---|
committer | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-11-28 16:02:14 +0000 |
commit | ae46dfee1cea41c53adbc59d433fc5f047c51c32 (patch) | |
tree | a66b931e1e4ae67a0fcea034e11fca49eec5b73e | |
parent | de914acf4bb29d1ba2042c6fc096e4046b0f0985 (diff) |
[ocamlbuild] Add the Digest_cache module.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8663 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | ocamlbuild/digest_cache.ml | 41 | ||||
-rw-r--r-- | ocamlbuild/digest_cache.mli | 17 | ||||
-rw-r--r-- | ocamlbuild/ocamlbuild_pack.mlpack | 1 |
3 files changed, 59 insertions, 0 deletions
diff --git a/ocamlbuild/digest_cache.ml b/ocamlbuild/digest_cache.ml new file mode 100644 index 000000000..95ddfed1c --- /dev/null +++ b/ocamlbuild/digest_cache.ml @@ -0,0 +1,41 @@ +(***********************************************************************) +(* 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 Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* Original author: Nicolas Pouillard *) + +open My_std +open Pathname.Operators + +let digests = Hashtbl.create 103 + +let get = Hashtbl.find digests + +let put = Hashtbl.replace digests + +let _digests = lazy (Pathname.pwd / !Options.build_dir / (Pathname.mk "_digests")) + +let finalize () = + with_output_file !*_digests begin fun oc -> + Hashtbl.iter begin fun name digest -> + Printf.fprintf oc "%S: %S\n" name digest + end digests + end + +let init () = + Shell.chdir !Options.build_dir; + if Pathname.exists !*_digests then + with_input_file !*_digests begin fun ic -> + try while true do + let l = input_line ic in + Scanf.sscanf l "%S: %S" put + done with End_of_file -> () + end; + My_unix.at_exit_once finalize diff --git a/ocamlbuild/digest_cache.mli b/ocamlbuild/digest_cache.mli new file mode 100644 index 000000000..7fb389eb4 --- /dev/null +++ b/ocamlbuild/digest_cache.mli @@ -0,0 +1,17 @@ +(***********************************************************************) +(* 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 Q Public License version 1.0. *) +(* *) +(***********************************************************************) + +(* Original author: Nicolas Pouillard *) + +val init : unit -> unit + +val get : string -> string +val put : string -> string -> unit diff --git a/ocamlbuild/ocamlbuild_pack.mlpack b/ocamlbuild/ocamlbuild_pack.mlpack index 805eefe5e..acc3aa6a3 100644 --- a/ocamlbuild/ocamlbuild_pack.mlpack +++ b/ocamlbuild/ocamlbuild_pack.mlpack @@ -36,3 +36,4 @@ Ocaml_tools Ocaml_compiler Ocaml_dependencies Exit_codes +Digest_cache |