Exclusively use ocamlfind; source documentation generation.
- Stripped portions of `myocamlbuild{,_config}.ml' that seem useless when `-use-ocamlfind' is passed to ocamlbuild. - Added some code in `myocamlbuild_config.ml' to be able to generate documentation by merging interface and implementation files.
This commit is contained in:
parent
8aeab651ce
commit
10bdab4dc6
10 changed files with 48 additions and 83 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,3 +28,4 @@ test/_check_builds
|
|||
lib/java/.classpath
|
||||
/test/async/build/*
|
||||
/test/image_filters/java/*
|
||||
compiler/doc.odocl
|
||||
|
|
|
@ -47,3 +47,10 @@ endif
|
|||
|
||||
clean:
|
||||
$(OCAMLBUILD) -clean
|
||||
|
||||
.PHONY: doc
|
||||
doc:
|
||||
find _build -regex '.*.cmi?' -printf '%f\n' \
|
||||
| sed -e '/ocamlbuild/ d; s/\(.*\)\.cmi$$/\u\1/' \
|
||||
| sort > doc.odocl;
|
||||
$(OCAMLBUILD) doc.docdir/index.html
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<global> or <utilities> or <minils> or <heptagon> or <main> or <obc>:include
|
||||
<**/*.ml>: debug, dtypes, pkg_ocamlgraph
|
||||
<preproc.ml>: camlp4of, use_camlp4
|
||||
true:use_menhir
|
||||
<**/*.{byte,native}>: use_unix, use_str, debug, custom, pkg_menhirLib, pkg_ocamlgraph
|
||||
<**/*.ml>: debug, dtypes, package(ocamlgraph)
|
||||
<preproc.ml>: camlp4of, package(camlp4)
|
||||
true: use_menhir
|
||||
|
||||
<main/hepts.ml>: pkg_lablgtk2, thread
|
||||
<main/hepts.{byte,native}>: pkg_lablgtk2, thread
|
||||
<**/*.{byte,native}>: package(unix), package(str), debug, custom
|
||||
<**/heptc.{byte,native}>: package(menhirLib), package(ocamlgraph)
|
||||
<main/hepts.{ml,byte,native}>: package(lablgtk2), thread
|
||||
|
|
|
@ -1 +1 @@
|
|||
<hept_parser.ml>: pkg_menhirLib
|
||||
<hept_parser.ml>: package(menhirLib)
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
|
||||
open Misc
|
||||
open Modules
|
||||
open Location
|
||||
open Compiler_utils
|
||||
open Compiler_options
|
||||
|
||||
|
|
1
compiler/minils/ctrl-n/_tags
Normal file
1
compiler/minils/ctrl-n/_tags
Normal file
|
@ -0,0 +1 @@
|
|||
<*.mli>: doc_use_interf_n_implem, merge(A)
|
|
@ -31,7 +31,6 @@ open Ocamlbuild_plugin.Options
|
|||
open Myocamlbuild_config
|
||||
|
||||
let df = function
|
||||
| Before_options -> ocamlfind_before_options ()
|
||||
| After_rules ->
|
||||
ocamlfind_after_rules ();
|
||||
|
||||
|
|
|
@ -28,85 +28,44 @@
|
|||
(***********************************************************************)
|
||||
open Ocamlbuild_plugin
|
||||
|
||||
(* these functions are not really officially exported *)
|
||||
let run_and_read = Ocamlbuild_pack.My_unix.run_and_read
|
||||
let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings
|
||||
|
||||
let split s ch =
|
||||
let x = ref [] in
|
||||
let rec go s =
|
||||
let pos = String.index s ch in
|
||||
x := (String.before s pos)::!x;
|
||||
go (String.after s (pos + 1))
|
||||
in
|
||||
try
|
||||
go s
|
||||
with Not_found -> !x
|
||||
|
||||
let split_nl s = split s '\n'
|
||||
|
||||
let before_space s =
|
||||
try
|
||||
String.before s (String.index s ' ')
|
||||
with Not_found -> s
|
||||
|
||||
(* this lists all supported packages *)
|
||||
let find_packages () =
|
||||
List.map before_space (split_nl & run_and_read "ocamlfind list")
|
||||
|
||||
(* this is supposed to list available syntaxes, but I don't know how to do it. *)
|
||||
let find_syntaxes () = ["camlp4o"; "camlp4r"]
|
||||
|
||||
(* ocamlfind command *)
|
||||
let ocamlfind x = S[A"ocamlfind"; x]
|
||||
|
||||
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)
|
||||
|
||||
let ocamlfind_before_options () =
|
||||
(* by using Before_options one let command line options have an higher priority *)
|
||||
(* on the contrary using After_options will guarantee to have the higher priority *)
|
||||
|
||||
(* override default commands by ocamlfind ones *)
|
||||
Options.ocamlc := ocamlfind & A"ocamlc";
|
||||
Options.ocamlopt := ocamlfind & A"ocamlopt";
|
||||
Options.ocamldep := ocamlfind & A"ocamldep";
|
||||
Options.ocamldoc := ocamlfind & A"ocamldoc";
|
||||
Options.ocamlmktop := ocamlfind & A"ocamlmktop"
|
||||
|
||||
let ocamlfind_after_rules () =
|
||||
(* When one link an OCaml library/binary/package, one should use -linkpkg *)
|
||||
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
|
||||
|
||||
(* For each ocamlfind package one inject the -package option when
|
||||
* compiling, computing dependencies, generating documentation and
|
||||
* linking. *)
|
||||
List.iter begin fun pkg ->
|
||||
flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg];
|
||||
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg];
|
||||
flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg];
|
||||
flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg];
|
||||
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg];
|
||||
end (find_packages ());
|
||||
(* 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 ());
|
||||
|
||||
(* 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 ());
|
||||
(* Use both ml and mli files to build documentation: *)
|
||||
rule "ocaml: ml & mli -> odoc"
|
||||
~insert:`top
|
||||
~tags:["ocaml"; "doc"; "doc_use_interf_n_implem"]
|
||||
~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;
|
||||
|
||||
(* The default "thread" tag is not compatible with ocamlfind.
|
||||
Indeed, the default rules add the "threads.cma" or "threads.cmxa"
|
||||
options when using this tag. When using the "-linkpkg" option with
|
||||
ocamlfind, this module will then be added twice on the command line.
|
||||
|
||||
To solve this, one approach is to add the "-thread" option when using
|
||||
the "threads" package using the previous plugin.
|
||||
*)
|
||||
flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
|
||||
flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
|
||||
flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
|
||||
(* Specifying merge options. *)
|
||||
pflag ["ocaml"; "doc"; "doc_use_interf_n_implem"] "merge"
|
||||
(fun s -> S[A"-m"; A s]);
|
||||
|
|
|
@ -16,7 +16,7 @@ INSTALL_BINDIR=$(bindir)
|
|||
INSTALL_LIBDIR=$(libdir)/heptagon
|
||||
STDLIB_DIR=@stdlib_dir@
|
||||
|
||||
OCAMLBUILD=STDLIB=$(STDLIB_DIR) @OCAMLBUILD@
|
||||
OCAMLBUILD=STDLIB=$(STDLIB_DIR) @OCAMLBUILD@ -use-ocamlfind
|
||||
|
||||
TARGET=byte
|
||||
ENABLE_SIMULATOR=@enable_simulator@
|
||||
|
|
2
heptc
2
heptc
|
@ -33,7 +33,7 @@ then
|
|||
HEPTC=$HEPTC_DEBUG
|
||||
else
|
||||
pushd "$COMPILER_DIR" > /dev/null
|
||||
ocamlbuild -j 0 "$COMPILER"
|
||||
ocamlbuild -use-ocamlfind -j 0 "$COMPILER"
|
||||
popd > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue