Merge commit 'ocaml3102'
[ocaml.git] / ocamlbuild / flags.ml
blob229086373125bdba42312e052026d6de5a0574d7
1 (***********************************************************************)
2 (* ocamlbuild *)
3 (* *)
4 (* Nicolas Pouillard, Berke Durak, projet Gallium, INRIA Rocquencourt *)
5 (* *)
6 (* Copyright 2007 Institut National de Recherche en Informatique et *)
7 (* en Automatique. All rights reserved. This file is distributed *)
8 (* under the terms of the Q Public License version 1.0. *)
9 (* *)
10 (***********************************************************************)
12 (* $Id$ *)
13 (* Original author: Nicolas Pouillard *)
14 open Command
15 open Bool (* FIXME remove me *)
16 open Tags.Operators
17 let all_flags = ref []
19 let of_tags tags =
20 S begin
21 List.fold_left begin fun acc (xtags, xflags) ->
22 if Tags.does_match tags xtags then xflags :: acc
23 else acc
24 end [] !all_flags
25 end
27 let () = Command.tag_handler := of_tags
29 let of_tag_list x = of_tags (Tags.of_list x)
31 let set_flags tags flags =
32 all_flags := (tags, flags) :: !all_flags
34 let flag tags flags = set_flags (Tags.of_list tags) flags
36 let add x xs = x :: xs
37 let remove me = List.filter (fun x -> me <> x)
38 let to_spec l =
39 S begin
40 List.fold_right begin fun (x, y) acc ->
41 A ("-"^x) :: A y :: acc
42 end l []
43 end
45 let get_flags () = !all_flags