From: Erick Tryzelaar <erickt@dslextreme.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] ocamlbuild and adding files to be sanitized
Date: Wed, 08 Aug 2007 01:48:10 -0700 [thread overview]
Message-ID: <46B9834A.3010307@dslextreme.com> (raw)
In-Reply-To: <28ac8a6d75ea10266a97edca.20070806025049.revpxg@www.dslextreme.com>
erickt@dslextreme.com wrote:
> I'm finishing up getting ocamlbuild to work with the dypgen parser, but I
> can't yet figure out how to get ocamlbuild to automatically list the .ml
> and .mli of the .dyp parser as microbes to be cleaned in sanitize.sh. It
> doesn't look like the hygiene or fda modules are exposed in the plugin. Is
> there any way to do it other than manually replicate the functionality in
> the {Before,After}_hygiene dispatch hook?
I was wrong, it looks like these modules are exposed, through
Ocamlbuild_pack. However, I cannot add sanitize rules to the already
existing set. I have to replicate the functionality with a dispatch
call, like this:
myocamlbuild.ml:
let laws =
[
{ law_name = "Leftover dypgen-generated files";
law_rules = [Implies_not(".dyp",".ml"); Implies_not(".dyp",".mli")];
law_penalty = Fail }
]
;;
dispatch begin function
| Before_rules ->
begin
let evil = ref false in
match !Options.entry with
| None -> ();
| Some entry ->
match check
?sanitize:
begin
if !Options.sanitize then
Some(!Options.sanitization_script)
else
None
end
laws entry
with
| [] -> ()
| stuff ->
List.iter
begin fun (law, msgs) ->
Printf.printf "%s: %s:\n"
(match law.law_penalty with
| Warn -> "Warning"
| Fail ->
if not !evil then
begin
Printf.printf "IMPORTANT: I cannot work with
leftover compiled files.\n%!";
evil := true;
end;
"ERROR")
law.law_name;
List.iter (Printf.printf " %s\n") msgs
end
stuff;
if !evil then raise Fda.Exit_hygiene_failed;
end
...
end;;
This is copied almost exactly from fda.ml, but since it's not exposed, I
can't use it. It would be great if the Fda module could model after the
Tags model, and have an interface like this:
fda.mli:
...
val law ?penalty:Hygiene.penalty -> string -> Hygiene.rule list
...
fda.ml:
...
let all_laws = ref [...]
let law ?(penalty=Fail) name rules =
all_laws := { law_name = name; law_rules = rules; law_penalty =
penalty } :: !all_laws
...
Then, I could easily replace my code with this:
myocamlbuild.ml:
open Ocamlbuild_pack.Fda;;
open Ocamlbuild_pack.Hygiene;;
law "Leftover dypgen-generated files" [Implies_not(".dyp",".ml");
Implies_not(".dyp",".mli")];;
dispatch begin function
...
end;;
Would this be useful for others?
next prev parent reply other threads:[~2007-08-08 8:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-06 9:50 erickt
2007-08-08 8:48 ` Erick Tryzelaar [this message]
2007-08-09 18:34 ` [Caml-list] " Nicolas Pouillard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46B9834A.3010307@dslextreme.com \
--to=erickt@dslextreme.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).