2012-06-27 18:09:30 +02:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon *)
|
|
|
|
(* *)
|
|
|
|
(* Gwenael Delaval, LIG/INRIA, UJF *)
|
|
|
|
(* Leonard Gerard, Parkas, ENS *)
|
|
|
|
(* Adrien Guatto, Parkas, ENS *)
|
|
|
|
(* Cedric Pasteur, Parkas, ENS *)
|
2012-06-29 01:43:15 +02:00
|
|
|
(* Marc Pouzet, Parkas, ENS *)
|
2012-06-27 18:09:30 +02:00
|
|
|
(* *)
|
|
|
|
(* Copyright 2012 ENS, INRIA, UJF *)
|
|
|
|
(* *)
|
|
|
|
(* This file is part of the Heptagon compiler. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is free software: you can redistribute it and/or modify it *)
|
|
|
|
(* under the terms of the GNU General Public License as published by *)
|
|
|
|
(* the Free Software Foundation, either version 3 of the License, or *)
|
|
|
|
(* (at your option) any later version. *)
|
|
|
|
(* *)
|
|
|
|
(* Heptagon is distributed in the hope that it will be useful, *)
|
|
|
|
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
|
|
|
|
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
|
|
|
|
(* GNU General Public License for more details. *)
|
|
|
|
(* *)
|
|
|
|
(* You should have received a copy of the GNU General Public License *)
|
|
|
|
(* along with Heptagon. If not, see <http://www.gnu.org/licenses/> *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
2011-10-20 18:06:23 +02:00
|
|
|
open Ocamlbuild_plugin
|
|
|
|
|
|
|
|
(* this is supposed to list available syntaxes, but I don't know how to do it. *)
|
|
|
|
let find_syntaxes () = ["camlp4o"; "camlp4r"]
|
|
|
|
|
2011-11-14 10:52:06 +01:00
|
|
|
let ocamlfind_query pkg =
|
|
|
|
let cmd = Printf.sprintf "ocamlfind query %s" (Filename.quote pkg) in
|
|
|
|
Ocamlbuild_pack.My_unix.run_and_open cmd (fun ic -> input_line ic)
|
|
|
|
|
2011-10-20 18:06:23 +02:00
|
|
|
let ocamlfind_after_rules () =
|
|
|
|
|
2013-11-08 15:46:31 +01:00
|
|
|
(* Like -package but for extensions syntax. Morover -syntax is useless
|
|
|
|
* when linking. *)
|
|
|
|
List.iter begin fun syntax ->
|
|
|
|
flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
|
|
|
|
flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
|
|
|
|
flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
|
|
|
|
flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
|
|
|
|
end (find_syntaxes ());
|
2011-10-20 18:06:23 +02:00
|
|
|
|
2013-11-08 18:51:06 +01:00
|
|
|
flag ["ocaml"; "doc"; "thread"] & S[A"-I"; A"+threads"];
|
|
|
|
|
2013-11-08 15:46:31 +01:00
|
|
|
(* Use both ml and mli files to build documentation: *)
|
|
|
|
rule "ocaml: ml & mli -> odoc"
|
|
|
|
~insert:`top
|
|
|
|
~prod:"%.odoc"
|
|
|
|
(* "%.cmo" so that cmis of ml dependencies are already built: *)
|
|
|
|
~deps:["%.ml"; "%.mli"; "%.cmo"]
|
|
|
|
begin fun env build ->
|
|
|
|
let mli = env "%.mli" and ml = env "%.ml" and odoc = env "%.odoc" in
|
|
|
|
let tags =
|
|
|
|
(Tags.union (tags_of_pathname mli) (tags_of_pathname ml))
|
|
|
|
++"doc_use_interf_n_implem"++"ocaml"++"doc" in
|
|
|
|
let include_dirs = Pathname.include_dirs_of (Pathname.dirname ml) in
|
|
|
|
let include_flags =
|
|
|
|
List.fold_right (fun p acc -> A"-I" :: A p :: acc) include_dirs [] in
|
|
|
|
Cmd (S [!Options.ocamldoc; A"-dump"; Px odoc;
|
|
|
|
T (tags++"doc"++"pp"); S (include_flags);
|
|
|
|
A"-intf"; P mli; A"-impl"; P ml])
|
|
|
|
end;
|
2011-10-20 18:06:23 +02:00
|
|
|
|
2013-11-08 15:46:31 +01:00
|
|
|
(* Specifying merge options. *)
|
|
|
|
pflag ["ocaml"; "doc"; "doc_use_interf_n_implem"] "merge"
|
|
|
|
(fun s -> S[A"-m"; A s]);
|