Commit a72981c0 authored by Gerd Stolpmann's avatar Gerd Stolpmann

Merge branch 'master' of gitssh.camlcity.org:gerd/lib-findlib

parents 7e2045cd fe7e633e
......@@ -2365,6 +2365,28 @@ omit "./" to search it, and you can prefix it with "@name/" if the command
is taken from another package "name").
</para>
<para>For more complex scenarios, additional options or
arguments for the ppx preprocessor can be specified in descendant
packages with the "ppxopt" property. Package "A" might provide a
generic ppx preprocessor with a META file containing
<programlisting>
ppx = "./generic_ppx"
</programlisting>
Package B might instantiate that preprocessor with
<programlisting>
requires = "A"
ppxopt = "A,ppx_b.cmo"
</programlisting>
In this case "ocamlfind ocamlc -package B" would
add <literal>-ppx "path_to_A/genric_ppx ppx_b.cmo"</literal> to
the ocamlc invocation. The format of the "ppxopt" property is
specified in the findlib reference manual.
</para>
<para>This feature is still a bit experimental.</para>
......
......@@ -28,6 +28,7 @@
or: <link linkend="ocamlfind.remove">ocamlfind remove [-help | other options] <replaceable>package_name</replaceable></link>
or: <link linkend="ocamlfind.list">ocamlfind lint <replaceable>META</replaceable></link>
or: <link linkend="ocamlfind.list">ocamlfind list [-describe]</link>
or: <link linkend="ocamlfind.printppx">ocamlfind printppx [-help | other options] <replaceable>package_name</replaceable> ...</link>
or: <link linkend="ocamlfind.printconf">ocamlfind printconf [ variable ]</link>
or: <link linkend="ocamlfind.pkgcmd">ocamlfind <replaceable>package</replaceable>/<replaceable>command</replaceable> <replaceable>arg</replaceable> ...</link>
......@@ -495,6 +496,13 @@ The options relevant for the preprocessor are the following:
<listitem><para>This argument is passed to the camlp4 call.
</para></listitem>
</varlistentry>
<varlistentry>
<term>-ppxopt <replaceable>package</replaceable>,<replaceable>arg</replaceable></term>
<listitem><para>Add <replaceable>arg</replaceable> to the ppx
preprocessor invocation specified via the "ppx" property in
the META file of <replaceable>package</replaceable>.
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
......@@ -1212,6 +1220,48 @@ outputs the package descriptions, too.
<!-- ********************************************************************** -->
<refsect1>
<title><anchor id="ocamlfind.printppx">
THE "printppx" SUBCOMMAND
</title>
<refsect2>
<title>Synopsis</title>
<programlisting>
ocamlfind printppx
[ -predicates <replaceable>pred-name-list</replaceable> ]
[ -ppxopt <replaceable>package</replaceable>,<replaceable>arg</replaceable> ]
<replaceable>package</replaceable> ...
</programlisting>
</refsect2>
<refsect2>
<title>Description</title>
<para>
This command prints the ppx preprocessor options as they would
occur in an OCaml compiler invocation for the packages listed in
the command. The output includes one "-ppx" option for each
preprocessor. The possible options have the same meaning as for
"ocamlfind ocamlc". The option "-predicates" adds assumed
predicates and
"-ppxopt <replaceable>package</replaceable>,<replaceable>arg</replaceable>"
adds "<replaceable>arg</replaceable>" to the ppx invocation of
package <replaceable>package</replaceable>.
</para>
<para>
The output of "ocamlfind printppx" will contain quotes
"<literal>"</literal>" for ppx commands that contain
space-separated arguments. In this case <literal>$(ocamlfind
printppx ...)</literal> won't work as naively expected, because
many shells (including bash and dash) perform field splitting on
the result of command substitutions without honoring quotes.
</para>
</refsect2>
</refsect1>
<!-- ********************************************************************** -->
<refsect1>
<title><anchor id="ocamlfind.lint">
THE "lint" SUBCOMMAND
......
......@@ -106,7 +106,8 @@ FORMAT="LINESPECIFIC"
>s</REPLACEABLE> |
-pp |
-descendants | -d |
-recursive | -r ] <REPLACEABLE
-recursive | -r
-qe | -qo] <REPLACEABLE
>package</REPLACEABLE> ...</PROGRAMLISTING></REFSECT2><REFSECT2
><TITLE
>Description</TITLE><PARA
......@@ -214,7 +215,15 @@ MOREINFO="NONE"
it is not needed to set -predicates, except you need the archives (then add
-predicates byte). This option implies <LITERAL
MOREINFO="NONE"
>-recursive</LITERAL>.</PARA></LISTITEM></VARLISTENTRY></VARIABLELIST></REFSECT2><REFSECT2
>-recursive</LITERAL>.</PARA></LISTITEM></VARLISTENTRY><VARLISTENTRY
><TERM
>-qe</TERM><LISTITEM
><PARA
>Do not print most errors to stderr, just set the exit code</PARA></LISTITEM></VARLISTENTRY><VARLISTENTRY
><TERM
>-qo</TERM><LISTITEM
><PARA
>Do not print the regular output.</PARA></LISTITEM></VARLISTENTRY></VARIABLELIST></REFSECT2><REFSECT2
><TITLE
>Placeholders meaningful in the -format option</TITLE><VARIABLELIST
><VARLISTENTRY
......
......@@ -11,7 +11,7 @@ exception Silent_error;;
type mode =
M_use | M_query | M_install | M_remove | M_compiler of string | M_dep
| M_printconf | M_list | M_browser | M_call of (string*string)
| M_doc | M_lint
| M_doc | M_lint | M_printppx
;;
......@@ -202,6 +202,11 @@ let arg n =
;;
let escape_if_needed s =
if String.contains s ' ' then "\"" ^ String.escaped s ^ "\"" else s
;;
let use_package prefix pkgnames =
(* may raise No_such_package *)
let pdirs =
......@@ -345,8 +350,6 @@ type verbosity =
let run_command ?filter verbose cmd args =
let escape_if_needed s =
if String.contains s ' ' then "\"" ^ String.escaped s ^ "\"" else s in
let printable_cmd =
cmd ^ " " ^ String.concat " " (List.map escape_if_needed args) in
( match verbose with
......@@ -2454,6 +2457,34 @@ let lint () =
;;
(** print ppx options *)
let print_ppx () =
let packages = ref [] in
let predicates = ref [] in
let ppx_opts = ref [] in
let add_pred =
Arg.String (fun s -> predicates := !predicates @ (Fl_split.in_words s)) in
let add_ppx_opt =
Arg.String (fun s -> ppx_opts := !ppx_opts @ [s]) in
parse_args
[ "-predicates", add_pred,
" specifies comma-separated list of assumed predicates";
"-ppxopt", add_ppx_opt,
"<pkg>,<opts> Append options <opts> to ppx invocation for package <pkg>";
]
(fun p -> packages := !packages @ [p])
"usage: ocamlfind printppx [options] package ...";
let ppx_commands =
process_ppx_spec !predicates !packages !ppx_opts
in
print_endline (String.concat " " (List.map escape_if_needed ppx_commands))
;;
let rec select_mode () =
let k = !Arg.current in
let m_string = try arg (k+1) with Not_found -> raise Usage in
......@@ -2475,6 +2506,7 @@ let rec select_mode () =
| ("printconf"|"-printconf") -> incr Arg.current; M_printconf
| ("list"|"-list") -> incr Arg.current; M_list
| ("lint"|"-lint") -> incr Arg.current; M_lint
| ("printppx"|"-printppx") -> incr Arg.current; M_printppx
| "-toolchain" ->
let t = try arg (k+2) with Not_found -> raise Usage in
Findlib.init ~toolchain:t ();
......@@ -2519,6 +2551,7 @@ let main() =
| M_call(pkg,cmd) -> ocamlcall pkg cmd
| M_compiler which -> ocamlc which ()
| M_lint -> lint()
| M_printppx -> print_ppx()
with
Usage ->
prerr_endline "Usage: ocamlfind query [-help | other options] <package_name> ...";
......@@ -2535,6 +2568,7 @@ let main() =
prerr_endline " or: ocamlfind ocamldoc [-help | other options] <file> ...";
prerr_endline " or: ocamlfind install [-help | other options] <package_name> <file> ...";
prerr_endline " or: ocamlfind remove [-help | other options] <package_name>";
prerr_endline " or: ocamlfind printppx [-help | other options] <package_name> ...";
prerr_endline " or: ocamlfind printconf [-help] [variable]";
prerr_endline " or: ocamlfind lint [-help] <file>";
prerr_endline " or: ocamlfind list";
......
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