| Anonymous | Login | Signup for a new account | 2013-05-26 07:59 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0005139 | OCaml | OCamlbuild (the tool) | public | 2010-08-31 16:24 | 2012-09-25 20:06 | |||
| Reporter | daweil | |||||||
| Assigned To | xclerc | |||||||
| Priority | normal | Severity | feature | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | 3.12.1+dev | ||||||
| Summary | 0005139: add possibilité to customize ocamlbuild options | |||||||
| Description | Could the list "spec" in the module Command of ocamlbuild be a reference on a liste, so that the writer of plugin could add its own options ? | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0005807) xclerc (developer) 2011-02-15 14:45 |
A function named 'add' has been added to 'Ocamlbuild_plugin.Options'. A command-line option named '-plugin-option' has been added to ocamlbuild (as it is necessary for the 'pristine' ocamlbuild to ignore added options). Here is a 'myocamlbuild.ml' example: --- open Ocamlbuild_plugin let () = dispatch begin function | Before_options -> Options.add ("-hello", Arg.String (Printf.printf "Hello %s.\n"), " classical example") | _ -> () end --- and an example of its execution: ocamlbuild -plugin-option '-hello' -plugin-option 'world' |
|
(0005808) daweil (reporter) 2011-02-15 15:32 |
That works but it is not what I wished! It looks quite heavy to use for the user and it looks redundant with the "--" option of ocamlbuild? What I wish is really to overwrite any ocamlbuild option, of course, at the own risk, of the plugin developper! and to call ocamlbuild directly with the option I want : ocamlbuild -myoption "hello world" I use ocamlbuild to build project which do not compile any ocaml code. I even want to hide from the user of the plugin I develop that my plugin is able to compile Ocaml code. That's why I was proposing to change the "spec" list of Ocamlbuild/options.ml into a reference to a list, or to offer a function in the plugin API that overwrite this list. |
|
(0005809) xclerc (developer) 2011-02-15 15:50 edited on: 2011-02-15 15:50 |
First, this is not redundant with the "--" option of ocamlbuild that is used to pass arguments to a produced executable, not to a plugin. Then, the ability to add an option, but not to bypass / remove any existing one is coherent with the behavior of both camlp4 and ocamldoc. Finally, my understanding is that what you are trying to achieve is not to be seen as a plugin task (I reckon this is a matter of taste). For what you are trying to achieve, I would suggest to use ocamlbuild as a library (that is "ocamlbuildlib.cm[x]a" in "$PREFIX/lib/ocaml/ocamlbuild"). |
|
(0005810) daweil (reporter) 2011-02-15 16:18 |
You're right. It's not a plugin that I wish but a "custom" build tool. In that case, what should be my entry points ? |
|
(0005811) xclerc (developer) 2011-02-15 16:27 edited on: 2011-02-15 16:28 |
You could take a look at "$ROOT/ocamlbuild/ocamlbuildlib.mllib" that defines the contents of the library. It contains the following modules: - Ocamlbuild_pack; - Ocamlbuild_plugin; - Ocamlbuild_unix_plugin; - Ocamlbuild_executor; where the three last ones are "top" modules while the first one is a package whose contents is defined by "$ROOT/ocamlbuild/ocamlbuild_pack.mlpack". It is too lengthy to list here, but basically you have access to all modules of the "$ROOT/ocamlbuild/directory" except "Ocamlbuild" that is just the entry point whose role is to call "Main.main". In "Ocamlbuild_pack", you will have access to the tags, rules, commands, etc. |
|
(0005812) daweil (reporter) 2011-02-15 16:35 |
OK. I understand that I should link with this library, specify my own command line options, customize the main.ml file to parse my options and link it with a copy of ocamlbuild.ml and of course with myocamlbuild.ml file. |
|
(0005813) xclerc (developer) 2011-02-15 16:41 |
Well, if your tool is a build tool that need no OCaml support, you can leave "Main" as it is today, and have your dedicated module that does its own analysis of the command line. This dedicated module can also receive was used to be in your "myocamlbuild.ml" file. After, all is a matter of taste and architecture; the only things you should not do is to call "Main.main", or "Options.init"... |
|
(0005814) daweil (reporter) 2011-02-15 17:05 |
OK, I'll try. |
|
(0005815) ygrek (reporter) 2011-02-16 09:51 |
Why would one want to add cmdline options to plugin when there is _tags file for that? It looks like duplicate functionality with no benefits.. |
|
(0005816) xclerc (developer) 2011-02-16 10:01 |
The "_tags" file is essentially a static one describing how to build while one may want to orthogonally pass options to dynamically change some parameters (e.g. debug enabled/disabled). Some simple things may be done through the "-tag" / "-tags" / "-tag-line" options, but more complex behavior may need the computation of a plugin. Hence the possibility to add a need command-line option. Moreover, as pointed out above, this possibility is coherent with camlp4 and ocamldoc plugins. |
|
(0005817) xclerc (developer) 2011-02-16 10:03 |
I mark the issue as "resolved/fixed", but the original reporter should feel free to add notes or to contact me by mail if the suggested path does not lead to success. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2010-08-31 16:24 | daweil | New Issue | |
| 2010-11-30 10:49 | xclerc | Status | new => assigned |
| 2010-11-30 10:49 | xclerc | Assigned To | => xclerc |
| 2011-02-10 16:16 | xclerc | Status | assigned => resolved |
| 2011-02-10 16:16 | xclerc | Fixed in Version | => 3.12.1+dev |
| 2011-02-10 16:16 | xclerc | Resolution | open => fixed |
| 2011-02-10 16:16 | xclerc | Status | resolved => feedback |
| 2011-02-10 16:16 | xclerc | Resolution | fixed => reopened |
| 2011-02-10 16:17 | xclerc | Status | feedback => assigned |
| 2011-02-15 14:45 | xclerc | Note Added: 0005807 | |
| 2011-02-15 14:45 | xclerc | Status | assigned => resolved |
| 2011-02-15 14:45 | xclerc | Resolution | reopened => fixed |
| 2011-02-15 15:32 | daweil | Note Added: 0005808 | |
| 2011-02-15 15:32 | daweil | Status | resolved => feedback |
| 2011-02-15 15:32 | daweil | Resolution | fixed => reopened |
| 2011-02-15 15:50 | xclerc | Note Added: 0005809 | |
| 2011-02-15 15:50 | xclerc | Note Edited: 0005809 | |
| 2011-02-15 16:18 | daweil | Note Added: 0005810 | |
| 2011-02-15 16:27 | xclerc | Note Added: 0005811 | |
| 2011-02-15 16:28 | xclerc | Note Edited: 0005811 | |
| 2011-02-15 16:35 | daweil | Note Added: 0005812 | |
| 2011-02-15 16:41 | xclerc | Note Added: 0005813 | |
| 2011-02-15 17:05 | daweil | Note Added: 0005814 | |
| 2011-02-16 09:51 | ygrek | Note Added: 0005815 | |
| 2011-02-16 10:01 | xclerc | Note Added: 0005816 | |
| 2011-02-16 10:03 | xclerc | Note Added: 0005817 | |
| 2011-02-16 10:03 | xclerc | Status | feedback => resolved |
| 2011-02-16 10:03 | xclerc | Resolution | reopened => fixed |
| 2012-02-02 15:17 | protz | Category | OCamlbuild => OCamlbuild (the tool) |
| 2012-09-25 20:06 | xleroy | Status | resolved => closed |
| Copyright © 2000 - 2011 MantisBT Group |