-
Notifications
You must be signed in to change notification settings - Fork 413
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
[configurator] Return pkg-config error to clients of new query API. #1886
Conversation
src/configurator/v1.mli
Outdated
val query_expr : t | ||
-> package:string | ||
-> expr:string | ||
-> (package_conf, string) Stdune.Either.t |
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.
Umm, exposing Stdune
this in this interface file may be a problem right?
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.
Yes, that's definitely not acceptable. Why don't you just return the result type? This will mean that this will require the result compatibility package in configurator, but I think that's acceptable.
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.
Umm, how should such package be exported without exposing Stdune
?
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.
You did exactly what I meant. The result type in stdune matches the one in stdlib so there's no need to export it from stdune.
00a841d
to
dc75ff8
Compare
Are we allowed to make a breaking change like this to |
dc75ff8
to
81ee509
Compare
I guess a way to check is to see if there are any |
81ee509
to
fd62b13
Compare
BTW, in general we should a bit be more strict about minor releases. I.e. we shouldn't introduce new functionalities in minor releases, just to give new functionalities a bit more time to mature in master. |
Yeah, that was definitely a mistake. I originally framed this issue as a "regression" so the new API was supposed to be a fix. I'll be more careful. |
@ejgallego you're getting a compilation error because of a bug on our end. Because we don't have transitive dependencies anymore, Just apply this patch:
And things should be fixed. In fact, we should depend on |
fd62b13
to
46cbc96
Compare
Ok, I see thanks! I was indeed puzzled by the error, but now I understand it. |
This doesn't work in 4.02 [as expected] so which compat module should we use for it? Should we open |
I think you can just use |
46cbc96
to
9b4ba9a
Compare
Let's go for it to try to get a full CI build. |
Hmm, I'm not a big fan of publicising |
9b4ba9a
to
9860e70
Compare
Indeed that seems to make the most sense, I've added a result type that can be deprecated and made into alias once 4.02 support is gone. I did grep for all the dependencies on dune in opam-repository and indeed there is no package depending on |
This seems like a case where the cure is worse than the disease. Users might easily introduce issues to their code by having it work against 1.7.2. There's nothing fundamentally wrong with the old function, perhaps we can just think of a new name for the function that returns a result? |
Well we'll get rid of In any case, I like the dune.result idea. Will implement it in a separate PR. |
This pr now needs #1892 |
Sure, I'll rename and add another function. IMO I would deprecate the old one right away, no reason to keep the API creep.
Cool, I'll wait for it to be merged. |
9860e70
to
a1efd95
Compare
Umm, I am not sure I understand how to use the new lib. |
I believe that this is all you need:
|
a1efd95
to
fafd0b4
Compare
Oh indeed thanks, I was missing the |
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.
Looks good. Just one minor nit. We prefer to keep all the general purpose functions in stdune.
src/configurator/v1.ml
Outdated
None | ||
Error stderr | ||
|
||
let res_forget = function Ok p -> Some p | Error _ -> None |
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.
This is a standard function, so let's just add this to Stdune.Result
. In base, this is called Or_error.ok
, but that's probably too cute. Let's just call it Result.to_option
or something.
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.
Indeed; I didn't add this to stdune I guess to keep it 1:1 to OCaml's result, but that's the wrong reason. Do you want me to update it on this PR or would you like it to introduce the change in a separate one?
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.
In stdune we extend the stdlib freely btw. We don't even bother to maintain compatibility. Dune_caml is the 1:1 "namespaced" clone, which we only need because Stdlib
is >= 4.07. Feel free to just do it here, in a new PR, or just push to master. This is a very a minor change.
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 will do it here as this PR is the first consumer of such a function.
fafd0b4
to
73e496a
Compare
9d4998f
to
b5ca0c0
Compare
Review re-requested; main point to discuss could be the deprecation of the 1.7.2 introduced function, otherwise this should be OK I think. |
The deprecation is acceptable to me. |
It is very convenient for configuration tools to be able to provide a better error message to the user when pkg-config fails. This was suggested by @garrigue. We take advantage of the newly [undocumented] API in 1.7.2 to modify its return type, but this could be a problem. If so, we will have to introduce yet another function if we want this functionality. We also update `src/configurator/dune` to include transitive dependencies as suggested by @rgrinberg Signed-off-by: Emilio Jesus Gallego Arias <e+git@x80.org>
b5ca0c0
to
0020f90
Compare
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 don't think we have to deprecate the function right away, but I'm fine if we do.
It is not used by anyone yet, so IMO it is better if we just try to avoid people use it at all as to have a more compact API. By the way, maybe at some point it would be useful for dune to include some kind of "dune-config" script? For example https://github.com/garrigue/lablgtk/blob/lablgtk3/src/dune_config.ml This allows people to write:
it seems to me that this is enough of a standard pattern as to avoid having N config-like scripts. |
At this point we might as well add a |
IMO that'd be a very nice solution and cover a lot of cases, let me open a ticket for it. |
@ejgallego btw, we usually merge our own PR's after approval. So if you're waiting for someone else to merge it, it's unlikely to happen. |
Indeed, sorry. I'm used to the coq model where you never merge your own PRs. |
I merged this myself to unblock 1.8 |
CHANGES: - Clean up watch mode polling loop: improves signal handling and error handling during polling (ocaml/dune#1912, fix ocaml/dune#1907, fix ocaml/dune#1671, @aalekseyev) - Change status messages during polling to be one-line, so that the messages are correctly erased by ^K. (ocaml/dune#1912, @aalekseyev) - Add support for `.cxx` extension for C++ stubs (ocaml/dune#1831, @rgrinberg) - Add `DUNE_WORKSPACE` variable. This variable is equivalent to setting `--workspace` in the command line. (ocaml/dune#1711, fix ocaml/dune#1503, @rgrinberg) - Add `c_flags` and `cxx_flags` to env profile settings (ocaml/dune#1700 and ocaml/dune#1800, @gretay-js) - Format `dune printenv` output (ocaml/dune#1867, fix ocaml/dune#1862, @emillon) - Add the `(promote-into <dir>)` and `(promote-until-clean-into <dir>)` modes for `(rule ...)` stanzas, so that files can be promoted in another directory than the current one. For instance, this is used in merlin to promote menhir generated files in a directory that depends on the version of the compiler (ocaml/dune#1890, @diml) - Improve error message when `dune subst` fails (ocaml/dune#1898, fix ocaml/dune#1897, @rgrinberg) - Add more GC counters to catapult traces (fix908, @rgrinberg) - Add a preprocessor shim for the `let+` syntax of OCaml 4.08 (ocaml/dune#1899, implements ocaml/dune#1891, @diml) - Fix generation of `.merlin` files on Windows. `\` characters needed to be escaped (ocaml/dune#1869, @mlasson) - Fix 0 error code when `$ dune format-dune-file` fails. (ocaml/dune#1915, fix ocaml/dune#1914, @rgrinberg) - Configurator: deprecated `query_expr` and introduced `query_expr_err` which is the same but with a better error in case it fails. (ocaml/dune#1886, @ejgallego)
CHANGES: - Clean up watch mode polling loop: improves signal handling and error handling during polling (ocaml/dune#1912, fix ocaml/dune#1907, fix ocaml/dune#1671, @aalekseyev) - Change status messages during polling to be one-line, so that the messages are correctly erased by ^K. (ocaml/dune#1912, @aalekseyev) - Add support for `.cxx` extension for C++ stubs (ocaml/dune#1831, @rgrinberg) - Add `DUNE_WORKSPACE` variable. This variable is equivalent to setting `--workspace` in the command line. (ocaml/dune#1711, fix ocaml/dune#1503, @rgrinberg) - Add `c_flags` and `cxx_flags` to env profile settings (ocaml/dune#1700 and ocaml/dune#1800, @gretay-js) - Format `dune printenv` output (ocaml/dune#1867, fix ocaml/dune#1862, @emillon) - Add the `(promote-into <dir>)` and `(promote-until-clean-into <dir>)` modes for `(rule ...)` stanzas, so that files can be promoted in another directory than the current one. For instance, this is used in merlin to promote menhir generated files in a directory that depends on the version of the compiler (ocaml/dune#1890, @diml) - Improve error message when `dune subst` fails (ocaml/dune#1898, fix ocaml/dune#1897, @rgrinberg) - Add more GC counters to catapult traces (fix908, @rgrinberg) - Add a preprocessor shim for the `let+` syntax of OCaml 4.08 (ocaml/dune#1899, implements ocaml/dune#1891, @diml) - Fix generation of `.merlin` files on Windows. `\` characters needed to be escaped (ocaml/dune#1869, @mlasson) - Fix 0 error code when `$ dune format-dune-file` fails. (ocaml/dune#1915, fix ocaml/dune#1914, @rgrinberg) - Configurator: deprecated `query_expr` and introduced `query_expr_err` which is the same but with a better error in case it fails. (ocaml/dune#1886, @ejgallego) - Make sure `(menhir (mode promote) ...)` stanzas are ignored when using `--ignore-promoted-rules` or `-p` (ocaml/dune#1917, @diml)
It is very convenient for configuration tools to be able to provide a
better error message to the user when pkg-config fails.
This was suggested by @garrigue.
We take advantage of the newly [undocumented] API in 1.7.2 to modify
its return type, but this could be a problem. If so, we will have to
introduce yet another function if we want this functionality.