ocamlbuild: turn the flags.ml structure into a record to ease adding metadata
I plan to add at least documentation and deprecation information to each flagset, so structuring it as a record is important. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14140 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
9d89a6b2a5
commit
53d1c7c63d
|
@ -15,24 +15,34 @@
|
||||||
open Command
|
open Command
|
||||||
open Bool (* FIXME remove me *)
|
open Bool (* FIXME remove me *)
|
||||||
open Tags.Operators
|
open Tags.Operators
|
||||||
let all_flags = ref []
|
|
||||||
|
|
||||||
let of_tags tags =
|
type decl = {
|
||||||
|
tags: Tags.t;
|
||||||
|
flags: Command.spec;
|
||||||
|
}
|
||||||
|
let flags_of_decl { flags; _ } = flags
|
||||||
|
let tags_of_decl { tags; _ } = tags
|
||||||
|
|
||||||
|
let all_decls = ref []
|
||||||
|
|
||||||
|
let of_tags matched_tags =
|
||||||
S begin
|
S begin
|
||||||
List.fold_left begin fun acc (xtags, xflags) ->
|
List.fold_left begin fun acc { tags; flags } ->
|
||||||
if Tags.does_match tags xtags then xflags :: acc
|
if Tags.does_match matched_tags tags then flags :: acc
|
||||||
else acc
|
else acc
|
||||||
end [] !all_flags
|
end [] !all_decls
|
||||||
end
|
end
|
||||||
|
|
||||||
let () = Command.tag_handler := of_tags
|
let () = Command.tag_handler := of_tags
|
||||||
|
|
||||||
let of_tag_list x = of_tags (Tags.of_list x)
|
let of_tag_list x = of_tags (Tags.of_list x)
|
||||||
|
|
||||||
let set_flags tags flags =
|
let add_decl decl =
|
||||||
all_flags := (tags, flags) :: !all_flags
|
all_decls := decl :: !all_decls
|
||||||
|
|
||||||
let flag tags flags = set_flags (Tags.of_list tags) flags
|
let flag tags flags =
|
||||||
|
let tags = Tags.of_list tags in
|
||||||
|
add_decl { tags; flags }
|
||||||
|
|
||||||
let pflag tags ptag flags =
|
let pflag tags ptag flags =
|
||||||
Param_tags.declare ptag
|
Param_tags.declare ptag
|
||||||
|
@ -41,14 +51,10 @@ let pflag tags ptag flags =
|
||||||
let add x xs = x :: xs
|
let add x xs = x :: xs
|
||||||
let remove me = List.filter (fun x -> me <> x)
|
let remove me = List.filter (fun x -> me <> x)
|
||||||
|
|
||||||
let get_flags () = !all_flags
|
|
||||||
|
|
||||||
|
|
||||||
let show_documentation () =
|
let show_documentation () =
|
||||||
let pp fmt = Log.raw_dprintf (-1) fmt in
|
let pp fmt = Log.raw_dprintf (-1) fmt in
|
||||||
let flags = get_flags () in
|
List.iter begin fun { tags; flags } ->
|
||||||
List.iter begin fun (tags, flag) ->
|
let sflag = Command.string_of_command_spec flags in
|
||||||
let sflag = Command.string_of_command_spec flag in
|
|
||||||
pp "@[<2>flag@ {. %a .}@ %S@]@\n@\n" Tags.print tags sflag
|
pp "@[<2>flag@ {. %a .}@ %S@]@\n@\n" Tags.print tags sflag
|
||||||
end flags;
|
end !all_decls;
|
||||||
pp "@."
|
pp "@."
|
||||||
|
|
Loading…
Reference in New Issue