Commit b389fc43 authored by POTTIER Francois's avatar POTTIER Francois

Updated myocamlbuild.ml to automatically add for-pack(MenhirLib) to the files...

Updated myocamlbuild.ml to automatically add for-pack(MenhirLib) to the files listed in menhirLib.mlpack.
This removes the need for explicitly listing these files in the file _tags.
parent 7614d0fc
......@@ -16,21 +16,3 @@
# Turn off assertions in some modules, where they are useful when debugging, but costly.
<LRijkstra.*>: noassert
# Every module that is part of MenhirLib must be tagged as such.
# If you change this list, please also update the files LICENSE
# and GNUmakefile in the toplevel directory, and update the file
# menhirLib.mlpack in this directory.
<convert.cmx>: for-pack(MenhirLib)
<engine.cmx>: for-pack(MenhirLib)
<engineTypes.cmx>: for-pack(MenhirLib)
<general.cmx>: for-pack(MenhirLib)
<IncrementalEngine.cmx>: for-pack(MenhirLib)
<infiniteArray.cmx>: for-pack(MenhirLib)
<inspectionTableFormat.cmx>: for-pack(MenhirLib)
<inspectionTableInterpreter.cmx>: for-pack(MenhirLib)
<LinearizedArray.cmx>: for-pack(MenhirLib)
<packedIntArray.cmx>: for-pack(MenhirLib)
<Printers.cmx>: for-pack(MenhirLib)
<rowDisplacement.cmx>: for-pack(MenhirLib)
<tableFormat.cmx>: for-pack(MenhirLib)
<tableInterpreter.cmx>: for-pack(MenhirLib)
# If you change this list, please also update the files LICENSE
# and GNUmakefile in the toplevel directory, and update the file
# _tags in this directory.
# and GNUmakefile in the toplevel directory.
Convert
Engine
EngineTypes
......
open Ocamlbuild_plugin
open Command
(* ---------------------------------------------------------------------------- *)
(* The following rules can be copied into other projects. *)
(* ---------------------------------------------------------------------------- *)
(* The auxiliary function [lines] reads a file, line by line. *)
let lines filename : string list =
let c = open_in filename in
let lines = ref [] in
try
while true do
lines := input_line c :: !lines
done;
assert false
with End_of_file ->
close_in c;
List.rev !lines
(* The auxiliary function [noncomment] recognizes a non-blank non-comment line. *)
let rec noncomment s i n =
i < n && match s.[i] with
| ' ' | '\t' | '\r' | '\n' ->
noncomment s (i + 1) n
| '#' ->
false
| _ ->
true
let noncomment s =
noncomment s 0 (String.length s)
(* ---------------------------------------------------------------------------- *)
(* If [m] is the name of a module, [cmx m] is the name of its [.cmx] file. There
are two candidate names, because of OCaml's convention where the first letter
of the file name is capitalized to obtain the module name. We decide between
the two by testing whether an [.ml] file exists. *)
let cmx (m : string) : string =
let candidate = m ^ ".cmx" in
if Sys.file_exists (m ^ ".ml") then candidate else String.uncapitalize candidate
(* ---------------------------------------------------------------------------- *)
(* If there is a file [foo.mlpack], then the modules that are listed in this
file are meant to be part of the library [Foo], and should receive the tag
[for-pack(Foo)]. ocamlbuild doesn't do this automatically, so we program
it. *)
(* The argument [basename] should be the basename of the [.mlpack] file. *)
let for_pack (basename : string) =
let filename = basename ^ ".mlpack" in
let modules = List.filter noncomment (lines filename) in
let library = String.capitalize basename in
let tags = [ Printf.sprintf "for-pack(%s)" library ] in
List.iter (fun m ->
tag_file (cmx m) tags
) modules
(* ---------------------------------------------------------------------------- *)
(* The following rules can be copied into other projects. *)
(* ---------------------------------------------------------------------------- *)
(* This rule generates an .ml file [target] from an .mly file [grammar] and a
.messages file [messages]. *)
......@@ -171,5 +232,6 @@ let () =
(* Add our rules after the standard ones. *)
parser_configuration();
flags();
for_pack "menhirLib";
| _ -> ()
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment