2 exception NoRuleFailure
8 | Many of filetype list
10 'a -> 'b -> filename -> string list
14 cmd : 'a -> filename list -> filename -> string list
18 let one_to_one src dest cmd = {
21 cmd = (fun a -> function [x] -> cmd a x | _ -> invalid_arg "")
24 let many_to_one src dest cmd = {
30 let is_reach dest {dest=dest'} =
37 let reachable dest rs =
38 rs +> List.filter (is_reach dest)
42 if f a b then a else b in
45 invalid_arg "empty list"
47 List.fold_left min y ys
49 let rec shortest rs src dest =
51 One x,One y when x = y ->
53 | One x,Many ys when [x] = ys ->
55 | One _,One _ | Many _,Many _| One _,Many _ | Many _,One _ ->
58 HList.concat_map (fun r ->
59 match shortest rs src r.src with
61 | Some rs -> [r::rs]) in
62 if shortests = [] then
65 Some (minimum_by (fun a b -> List.length a < List.length b) shortests)
69 Str.regexp ".*\\.\\(.*\\)$" in
70 if Str.string_match regexp x 0 then
73 invalid_arg "no suffix"
77 (Filename.chop_suffix name (suffix name))
80 let route rs inputs output =
86 Many (xs +> List.map suffix +> List.sort compare +>
87 ExtList.List.unique) in
89 One (suffix output) in
92 let commands ctx rs inputs output =
93 match route rs inputs output with
97 r +> List.rev +> map_accum_left
98 (fun inputs' {dest=dest; cmd=cmd} ->
99 [tmp output dest],cmd ctx inputs' @@ tmp output dest)
104 let temp_files ctx rs inputs output =
105 match route rs inputs output with
106 | None | Some [] | Some [_] ->