diff options
author | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-02-22 16:51:39 +0000 |
---|---|---|
committer | Nicolas Pouillard <np@nicolaspouillard.fr> | 2007-02-22 16:51:39 +0000 |
commit | 7a0e57b52518c0699aa619db57150fea0a4dacfa (patch) | |
tree | 874d0ab0a1982670637cdef219136931ee8d0233 | |
parent | 3ecf34d3a91e6b5fa5f0bfe00e98b4c313cc7a67 (diff) |
[ocamlbuild] Minor things. For details see the ChangeLog
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7897 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | ocamlbuild/ChangeLog | 11 | ||||
-rw-r--r-- | ocamlbuild/hygiene.ml | 3 | ||||
-rw-r--r-- | ocamlbuild/manual/manual.tex | 63 | ||||
-rw-r--r-- | ocamlbuild/my_std.ml | 2 | ||||
-rw-r--r-- | ocamlbuild/signatures.mli | 8 |
5 files changed, 78 insertions, 9 deletions
diff --git a/ocamlbuild/ChangeLog b/ocamlbuild/ChangeLog index 4583b908d..3043852bc 100644 --- a/ocamlbuild/ChangeLog +++ b/ocamlbuild/ChangeLog @@ -1,3 +1,14 @@ +2007-02-22 Nicolas Pouillard <nicolas.pouillard@gmail.com> + + ( & ), sanitize.sh, and the manual... + + * signatures.mli: Add ( & ). + + * hygiene.ml: Also clean the sanitize.sh script itself. + * my_std.ml: Add ( & ). + * manual/manual.tex: Some fixes and a section that I wrote but that's + needs reflexion about what solution we want to support. + 2007-02-22 Berke Durak <berke.durak@inria.fr> Implemented fixes suggested by Commissar Leroy. diff --git a/ocamlbuild/hygiene.ml b/ocamlbuild/hygiene.ml index 23b833759..365c99dfb 100644 --- a/ocamlbuild/hygiene.ml +++ b/ocamlbuild/hygiene.ml @@ -155,6 +155,9 @@ let check ?sanitize laws entry = fp oc "rm -f %s\n" (Shell.quote_filename_if_needed fn) end microbes; + (* Also clean itself *) + fp oc "# Also clean the script itself\n"; + fp oc "rm -f %s\n" (Shell.quote_filename_if_needed fn); close_out oc end; !penalties diff --git a/ocamlbuild/manual/manual.tex b/ocamlbuild/manual/manual.tex index 9f9bd4398..b9e4dea6f 100644 --- a/ocamlbuild/manual/manual.tex +++ b/ocamlbuild/manual/manual.tex @@ -76,15 +76,10 @@ you may also want to isolate calls to the non-API parts of the \ocb library from the rest of your plugin to to be able to keep the later when incompatible changes arise. -The way that \ocb handles the command-line options, the \texttt{\_tags} file, +The way that \ocb handles the command-line options, the \tags file, the target names, names of the tags, and so on, are not expected to change in incompatible ways. We intend to keep a project that compiles without a plugin compilable without modifications in the future. - -\begin{itemize} -\item Plugin API not stable -\item No built-in rules for creating toplevels or libraries -\end{itemize} %***) %(*** Using ocamlbuild \section{Using \ocb} @@ -528,7 +523,7 @@ either type: \begin{verbatim} % ocamlbuild -Is foo,bar,baz foo/main.native \end{verbatim} -or add the following line in the \texttt{\_tags} file +or add the following line in the \tags file \begin{verbatim} <foo> or <bar> or <baz>: include \end{verbatim} @@ -597,6 +592,55 @@ Another way is to use the tags file. \hline \end{tabular} \end{center} + +%%%%% \subsubsection{An example, dealing with some configuration variables} +%%%%% +%%%%% It's quite common to have in your sources some files that you want to access +%%%%% when your program is running. One often uses some variables that are setup by +%%%%% the end user. Now suppose that there is only two files that use these variables +%%%%% (mylib.ml and parseopt.ml). +%%%%% +%%%%% In the \tags file: +%%%%% \begin{verbatim} +%%%%% "mylib.ml" or "parseopt.ml": pp(sed -e "s,LIBDIR,/usr/local/lib/FOO,g") +%%%%% \end{verbatim} +%%%%% +%%%%% In fact that solution is not really acceptable, since the variable is hardcoded +%%%%% in the \tags file. Trying to workaround this issue by using some shell variable +%%%%% does not work either since the -pp argument will be escaped in simple quotes. +%%%%% Note also that using some script shell that will do that sed and use \verb'$LIBDIR' +%%%%% as a shell variable is not a good idea since \ocb don't know this dependency on that +%%%%% shell script. +%%%%% +%%%%% There is in fact at least two good solutions. The first is to tell that dependency +%%%%% using the \texttt{dep} function in your plugin. The second is simpler it just consist +%%%%% on generating some OCaml file at configure time. By naming this configuration file +%%%%% \texttt{myocamlbuild_config.ml} \ocb will make it also available to your plugin. +%%%%% +%%%%% In your \texttt{myocamlbuild_config.mli} interface: +%%%%% \begin{verbotim} +%%%%% val prefix : string +%%%%% val libdir : string +%%%%% \end{verbotim} +%%%%% +%%%%% And in your \texttt{configure} script +%%%%% \begin{verbatim} +%%%%% #!/bin/sh +%%%%% +%%%%% # Setting defaults values +%%%%% PREFIX=/usr/local +%%%%% LIBDIR=$PREFIX/lib/FOO +%%%%% CONF=myocamlbuild_config.ml +%%%%% +%%%%% # ... some shell to parse option and check configuration ... +%%%%% +%%%%% # Dumping the configuration as an OCaml file. +%%%%% rm -f $CONF +%%%%% echo "let prefix = \"$PREFIX\";;" >> $CONF +%%%%% echo "let libdir = \"$LIBDIR\";;" >> $CONF +%%%%% chmod -w $CONF +%%%%% \end{verbatim} + %***) %(*** Debugging and profiling \subsection{Debugging byte code and profiling native code} @@ -611,7 +655,7 @@ on the command line, or add a \begin{verbatim} true: debug \end{verbatim} -line to your \texttt{\_tags} file. +line to your \tags file. Please note that the byte-code profiler works in a wholly different way and is not supported by \ocb. %***) @@ -701,7 +745,7 @@ launch \ocb with the \texttt{-use-menhir} option or add a \begin{verbatim} true: use_menhir \end{verbatim} -line to your \texttt{\_tags} file. Note that there is currently no way +line to your \tags file. Note that there is currently no way of using \texttt{menhir} and \texttt{ocamlyacc} in the same execution of \ocb. %***) @@ -719,6 +763,7 @@ for different reasons (such as cross-compiling or using a wrapper such as \item \texttt{-ocamlyacc <command>} \item \texttt{-menhir <command>} \item \texttt{-ocamllex <command>} + \item \texttt{-ocamlmktop <command>} \item \texttt{-ocamlrun <command>} \end{itemize} diff --git a/ocamlbuild/my_std.ml b/ocamlbuild/my_std.ml index 9d3c0a97c..6a0351608 100644 --- a/ocamlbuild/my_std.ml +++ b/ocamlbuild/my_std.ml @@ -295,6 +295,8 @@ let ( !* ) = Lazy.force let ( @:= ) ref list = ref := !ref @ list +let ( & ) f x = f x + let print_string_list = List.print String.print module Digest = struct diff --git a/ocamlbuild/signatures.mli b/ocamlbuild/signatures.mli index 98b367ffd..e63719e5c 100644 --- a/ocamlbuild/signatures.mli +++ b/ocamlbuild/signatures.mli @@ -314,8 +314,16 @@ module type MISC = sig val copy_chan : in_channel -> out_channel -> unit val copy_file : string -> string -> unit val print_string_list : Format.formatter -> string list -> unit + + (** A shortcut to force lazy value (See {Lazy.force}). *) val ( !* ) : 'a Lazy.t -> 'a + (** The right associative application. + Useful when writing to much parentheses: + << f (g x ... t) >> becomes << f& g x ... t >> + << f (g (h x)) >> becomes << f& g& h x >> *) + val ( & ) : ('a -> 'b) -> 'a -> 'b + (** [r @:= l] is equivalent to [r := !r @ l] *) val ( @:= ) : 'a list ref -> 'a list -> unit |