1

I have written a myocamlbuild.ml after this manual containing the following code in order to not to have to enter in command line some flags each time compiling a test written with alcotest like ocamlbuild -use-ocamlfind -package alcotest test_foo.native

open Ocamlbuild_plugin

let () =
  dispatch & function
    | Before_rules ->
      pflag ["test_alcotest"] "package" & fun name -> S [A "-use-ocamlfind"; A "-package"; A name]
    | _ -> ()

I imagined the command ocamlbuild test_foo.native would read the tag I defined in _tags file as

<test_*.ml>: test_alcotest, package(alcotest)

and would call ocamlc.opt -c -o -use-ocamlfind -package alcotest test_foo.ml, but it wouldn't; instead it called ocamldep.opt -use-ocamlfind -package alcotest -pp '-use-ocamlfind -package alcotest' -modules test_foo.ml > test_foo.ml.depends how can I change that?

Morin
  • 93
  • 7

1 Answers1

0

There already exists a pre-defined package(X) parametrized tag. If you wish to use it, you don't need a myocamlbuild.ml; if you wish to override it to give it a different meaning, I would rather recommend using another name to avoid confusion.

If what you want to do is just to pass -package alcotest, you don't need a new flag definition. Just use

<test_*.ml>: package(alcotest)

and invoke ocamlbuild with ocamlbuild -use-ocamlfind.

gasche
  • 31,259
  • 3
  • 78
  • 100