ocamlbuild icon indicating copy to clipboard operation
ocamlbuild copied to clipboard

MPR#6097: Allow user to add new commandline options in the plugin.

Open damiendoligez opened this issue 9 years ago • 2 comments

PR transferred from https://caml.inria.fr/mantis/view.php?id=6097 [original reporter: @danmey ]

For instance user wants to options and tags for the js_of_ocaml compiler.

Then in his myocamlbuild.ml (s)he will say (roughly):

let jopts := ref ""
dispatch begin function
| Before_construct_options ->
  add_option ("-jopts", String (fun x -> jopts := !jopts ^ " " ^ x, " js_of_ocaml 
options")
| _ -> () end

of course that, and possibility of passing the options to the plugin, make is relatively easy to extend ocamlbuild itself not only with rules but also with new funcionality.

Then we can use the new options like this (hypothetically):

ocamlbuild -popts "-package js_of_ocaml.build" -jopts -pretty foo.js

(or use _tags to get the same functionality)

damiendoligez avatar Mar 01 '17 15:03 damiendoligez

Triage: this seems hard to implement as described for the same reasons as in https://github.com/ocaml/ocamlbuild/issues/185#issuecomment-283486418, but trivial to do with -tag.

whitequark avatar Mar 01 '17 22:03 whitequark

It is not clear to me why you say that this falls under the same issue as the comment in #185. Here the ideas is to add new options in the myocamlbuild plugin, so it seems that myocamlbuild.ml is a reasonable place to implement this (as long as it is put in Before_options, of course). Camlp4 plugins had access to a nice API to add their own command-line flag, and it was not used by many plugins but it was a nice convenience for those that had a use for it.

My own triaging judgment would be "that sounds reasonable, we welcome a pull request".

gasche avatar Mar 03 '17 15:03 gasche