Add --toolchain option, for ocamlbuild -toolchain#87
Add --toolchain option, for ocamlbuild -toolchain#87whitequark wants to merge 1 commit intodbuenzli:masterfrom whitequark:master
Conversation
|
I don't have this in my head but why can't this be simply defined by a configuration key, e.g. like in 2bf815d and appropriate lookup in |
No reason other than that I find the code of the new topkg very hard to follow.
This doesn't work on opam 1.x and I think it didn't properly work in opam 2.x either last time I checked that thread. |
Rather TOPKG_CONF_TOOLCHAIN |
|
Done, and works in opam-cross-* |
| Topkg_os.Cmd.run @@ | ||
| Topkg_cmd.(build_cmd ~use_toolchain:false c os %% v "-just-plugin") >>= fun () -> | ||
| Topkg_os.Cmd.run @@ | ||
| Topkg_cmd.(build_cmd ~use_toolchain:true c os %% of_list files) |
There was a problem hiding this comment.
I'm not very fond of this two level invocation here, in particular the docs here will need update. Is there a valid use case why ocamlbuild would use the toolchain argument to build its own plugin ? Shouldn't ocamlbuild's toolchain option simply affect the requested targets ?
There was a problem hiding this comment.
/cc @gasche since this is more a discussion about that toolchain support.
There was a problem hiding this comment.
Using -plugin-option "-toolchain ..." could also work, couldn't it? (See ocaml/ocamlbuild#129 for a clarification of the various plugin-build-vs-plugin-run options.)
There was a problem hiding this comment.
(If whitequark agrees that the right semantics for ocamlbuild would be to have -toolchain never apply to the plugin build, I'm not opposed to changing it, of course. I know nothing about cross-compilation so I'll mostly do as I'm told.)
There was a problem hiding this comment.
@gasche I had no idea -plugin-option existed, and I'm mildly confused as to its semantics. Does -plugin-option x mean "run ocamlbuild -just-plugin without x, then run ocamlbuild with x"? Or does it have different semantics depending on whether myocamlbuild.ml exists?
There was a problem hiding this comment.
Just to make it clear. I don't like the PR in this current state because for now users can reuse Pkg.build_cmd and simply add arguments (like -tag BLA options according to the configuration) to it without them having to redefine everything.
While this PR keeps backwards compat on this. Doing this after the PR, will break cross compilation for the package. So if possible the support for cross should go entirely in the definition of the build_cmd, if that is impossible we need to break the API and figure out a better way.
There was a problem hiding this comment.
@dbuenzli There is no need to separately invoke -just-plugin anymore because ocaml/ocamlbuild#130 (comment) got merged. I will update the PR shortly.
There was a problem hiding this comment.
@dbuenzli So, how do I get the --toolchain option actually picked up by the CLI? Once again topkg is completely opaque here...
There was a problem hiding this comment.
Your questions are completely obscure. In which context ? Configuration keys can be looked up with the configuration that is given to you in some contexts (e.g. package description describe, build description build). See the opaque API documentation.
There was a problem hiding this comment.
@dbuenzli Sorry for the opaque question, and thanks for your patience. The problem was not related to topkg after all, but was my mistake, several levels removed from topkg itself.
|
Ping? Also you'll have to update whatever process by which the natdynlink capability gets discovered to work with -toolchain, as this is another instance in which I found topkg too opaque to patch properly. |
I don't exactly what you see as obscure here. But in any case In any case, regarding natdynlink. The OCaml configuration is looked up using |
Thanks, the item #4 shows exactly the change that I need to perform: Cmd.(v "ocamlfind" % "mytool") if "mytool" is part of the OCaml tools that can be invoked through ocamlfind.This should be trivial to implement now. |
BTW I am very happy about having ocamlfind -toolchain as well as (now) ocamlbuild -toolchain. This makes it far easier to work with the majority of packages, which do not use topkg; for example I think (but haven't checked yet) that with the ocamlbuild patch, cross-compilation could be achieved for oasis packages with a single configure.ml option. Eventually I would like to generate cross-packages based on host-packages using a simple script instead of the current manual approach. Of course, first-class opam support would be better but I do not spend enough time changing them manually to justify implementing that and the opam team does not appear to have a strong interest in cross-compilation, seeing as to how little discussion ocaml/opam#2476 has generated. |
|
@dbuenzli I have updated the PR to address your concern about overriding build_cmd, and verified that it works with my opam-cross-* repositories. One unresolved question is: what do we do with the ocamlbuild dependency specification? Currently it's a
|
|
Looks right, but could you please document and expose the configuration key to the end users API around here. Also the documentation of the default build command here should be updated. You are right about the fact that |
I mean existing installs with pre-0.11.0 ocambuild will have to be upgraded, potentially triggering a lot of rebuilds. |
Done. |
|
Thanks ! Your patch is in as 05685ce. You may want to keep your fork around until a release is done because the current master depends on an unreleased version of cmdliner. |
|
@dbuenzli ack. There is also no ocamlbuild release to require as an opam dependency, yet. |
Depends on ocaml/ocamlbuild#125, fixes #86.