caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlbuild and adding files to be sanitized
@ 2007-08-06  9:50 erickt
  2007-08-08  8:48 ` [Caml-list] " Erick Tryzelaar
  2007-08-09 18:34 ` Nicolas Pouillard
  0 siblings, 2 replies; 3+ messages in thread
From: erickt @ 2007-08-06  9:50 UTC (permalink / raw)
  To: caml-list

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?

-e


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamlbuild and adding files to be sanitized
  2007-08-06  9:50 ocamlbuild and adding files to be sanitized erickt
@ 2007-08-08  8:48 ` Erick Tryzelaar
  2007-08-09 18:34 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Erick Tryzelaar @ 2007-08-08  8:48 UTC (permalink / raw)
  To: caml-list

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?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamlbuild and adding files to be sanitized
  2007-08-06  9:50 ocamlbuild and adding files to be sanitized erickt
  2007-08-08  8:48 ` [Caml-list] " Erick Tryzelaar
@ 2007-08-09 18:34 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-08-09 18:34 UTC (permalink / raw)
  To: Erick Tryzelaar; +Cc: Inria Ocaml Mailing List

Alas there is no way to do that in a clean way for the moment.

Excerpts from Erick Tryzelaar's message of Mon Aug 06 11:50:49 +0200 2007:
> 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?
> 
> -e
> 

-- 
Nicolas Pouillard aka Ertai


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-09 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-06  9:50 ocamlbuild and adding files to be sanitized erickt
2007-08-08  8:48 ` [Caml-list] " Erick Tryzelaar
2007-08-09 18:34 ` Nicolas Pouillard

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).