ocamlbuild,minor,improvement: Digest commands in such a way that one don't make too big strings.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8713 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Nicolas Pouillard 2007-12-18 08:55:48 +00:00
parent 515851721f
commit e94095e6b0
4 changed files with 20 additions and 6 deletions

View File

@ -317,7 +317,21 @@ let rec reduce x =
| [x] -> x
| xs -> S xs
let to_string_for_digest = to_string
let digest =
let list = List.fold_right in
let text x acc = Digest.string x :: acc in
let rec cmd =
function
| Cmd spec -> fun acc -> string_of_command_spec spec :: acc
| Seq seq -> list cmd seq
| Nop -> fun acc -> acc
| Echo(texts, dest_path) -> list text (dest_path :: texts)
in
fun x ->
match cmd x [] with
| [x] -> x
| xs -> Digest.string ("["^String.concat ";" xs^"]")
(*
let to_string_for_digest x =
let rec cmd_of_spec =

View File

@ -23,8 +23,8 @@ val string_target_and_tags_of_command_spec : spec -> string * string * Tags.t
val iter_tags : (Tags.t -> unit) -> t -> unit
(** Same as [to_string]. *)
val to_string_for_digest : t -> string
(** Digest the given command. *)
val digest : t -> Digest.t
(** Maximum number of parallel jobs. *)
val jobs : int ref

View File

@ -292,7 +292,7 @@ let rule name ?(tags=[]) ?(prods=[]) ?(deps=[]) ?prod ?dep ?stamp ?(insert = `bo
let prods = res_add Resource.import_pattern prods prod in
let code env build =
let cmd = code env build in
{ digest = Command.to_string_for_digest cmd
{ digest = Command.digest cmd
; command = cmd }
in
add_rule insert

View File

@ -221,10 +221,10 @@ module type COMMAND = sig
into command-line options. *)
val reduce : spec -> spec
(** Print a command. *)
(** Print a command (the format is not suitable to running the command). *)
val print : Format.formatter -> t -> unit
(** Convert a command to a string. *)
(** Convert a command to a string (same format as print). *)
val to_string : t -> string
(** Build a string representation of a command that can be passed to the