-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix jbuilder support without opam #179
Conversation
Could we add 4.05 to the CI matrix? |
It's on my todo list for later! |
https://github.com/dra27/jbuilder/tree/ci-4.05 - but in order to test with --dev, I presently have to do something which Jeremie has already rejected (altering the opam file). I'll see if I can find time to replace the entire script (there's no need to use opam at all for the CI) |
bin/main.ml
Outdated
let get_libdir context ~from_command_line = | ||
match from_command_line with | ||
| Some p -> Future.return (Path.of_string p) | ||
| None -> Context.install_ocaml_libdir context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default for --libdir
should be $prefix/lib
. This is what opam-installer
does. Otherwise, if you call jbuilder install --prefix ...
, it might install library files at a completely different location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is Context.install_ocaml_libdir
used? I propose:
- use
--libdir
if present - use
--prefix
if present with$prefix/lib
- use
Context.install_ocaml_libdir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, rebased and squashed
| Some s -> Path.absolute s | ||
| None -> | ||
(* If neither opam neither ocamlfind are present use stdlib dir *) | ||
t.stdlib_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a bit surprising that for the search path, jbuilder falls back to $(which ocamlc)/../../lib
and for installation it falls back to $(ocamlc -where)
. I don't claim that I made the right choice for the search path, happy to change it if the current default is wrong, but I think the two should be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously people used a lot -I +lib
, and it is the place that debian use. As a side note in many tools the default installation prefix is /usr/local
and not /usr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. opam-installer uses /usr/local
as default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opam-installer uses /usr/local as default
Do you want jbuilder to use this default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, the current default is where OCaml is installed which seems fine to me, especially if we install the library files in the stdlib directory
- change default findlib directory (ocamlc -where)
else | ||
return [] | ||
in | ||
findlib_path >>= fun findlib_path -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move this bit? It is now run after ocamlc -config
instead of in parallel with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I need the value of stdlib_dir
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, indeed
doc/usage.rst
Outdated
@@ -248,17 +248,27 @@ to be able to use ``jbuilder install``. | |||
Destination | |||
----------- | |||
|
|||
The place where the build artifacts are copied, usually referred as | |||
The place where the build artifacts (except ocaml libraries) are copied, usually referred as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ocaml libraries/library files/
, we usually copy other stuff as well, such as binaries (ppx, ...)
doc/usage.rst
Outdated
``/usr`` | ||
#. otherwise, take the parent of the directory where ``ocamlc`` was found. | ||
|
||
The ocaml libraries build artifacts are copied, referred as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
place
word missing. Same remark about ocaml libraries
doc/usage.rst
Outdated
The ocaml libraries build artifacts are copied, referred as | ||
**libdir**, is determined as follow for a given build context: | ||
|
||
#. if an explicit ``--libdir <path>`` argument is passed, use this path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing point about --prefix <path>
| Some s -> Path.absolute s | ||
| None -> | ||
(* If neither opam neither ocamlfind are present use stdlib dir *) | ||
t.stdlib_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. opam-installer uses /usr/local
as default
BTW, why not simply call opam-installer with the right options? Unless you are installing for multiple workspaces simultaneously, in which case you need opam, That would avoid adding more ad-hoc rules to jbuilder and relying even more on ocamlfind. |
What are the right options?
By default |
I imagine that it would be: $ opam-installer --libdir $(ocamlfind printconf destdir) foo.install |
Oh I see perhaps better what you mean. You are proposing that |
I'm not proposing to remove it, I think it's fine in its current state. I'm just saying that if you want more control, you can simply use opam-installer directly and set the parameters that suit your configuration. |
I was not clear with the problem I tried to fix in this MR. My problem is to install other people library that use jbuilder in a context without opam (example ocaml is installed using debian packages). For example the findlib package of debian already has all the interesting configuration
Is the installation in such setting not something that library developers want out-of-the-box? |
I suppose. Many people want to get rid of ocamlfind, the idea being that once we have namespaces we don't need ocamlfind and especially findlib names anymore. So I'm a bit reluctant to rely more on ocamlfind. For installation, given that we already require an external tool, it doesn't seem too bad to me to just use an external tool altogether. We could have a separate tool to handle installation for non-opam setups. |
It is simpler when the distribution could indicate where to install things in an uniform way instead for each project to guess for each distribution where to install things. We still generally need to know where to install things, of course in the namespace proposal
This PR just use it if it is present, I think it doesn't rely on it. |
Ok, I suppose this PR only uses ocamlfind if it's present in the PATH and in this case we can assume that it reflects the user setup. I'll read this one more time but I think I'm OK with it in the end. |
Ok, I merged this by hand and did some minor changes. I changed the rules so that we use |
Doesn't change that
opam-installer
must be available.Should fix #174 by:
libdir
ofopam-installer
for the case where libraries should not be installed in$PREFIX/lib
libdir
is:jbuilder install
ocamlfind printconf destdir
opam config lib