-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[nlohmann-json] Add option to control implicit conversions behaviour #22409
Conversation
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 new experimental fast check for PR issues. Please let us know if this bot is helpful!
PRs must add only one version and must not modify any published versions
When making any changes to a library, the version or port-version in vcpkg.json
or CONTROL
must be modified.
Error: Local changes detected for nlohmann-json but no changes to version or port version.
-- Version: 3.10.4
-- Old SHA: f948131b4bc6e2e9ae67cb7d40f5e930991fba21
-- New SHA: 4c6c6eeb8001078b424e858b49bd37e37a3990e3
-- Did you remember to update the version or port version?
-- Pass `--overwrite-version` to bypass this check.
***No files were updated.***
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout 1acb3e1999ee7b9f1e161b4f0937359e01c333e0 -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/n-/nlohmann-json.json b/versions/n-/nlohmann-json.json
index bd9d883..29cfd19 100644
--- a/versions/n-/nlohmann-json.json
+++ b/versions/n-/nlohmann-json.json
@@ -1,10 +1,5 @@
{
"versions": [
- {
- "git-tree": "4c6c6eeb8001078b424e858b49bd37e37a3990e3",
- "version-semver": "3.10.4",
- "port-version": 1
- },
{
"git-tree": "f948131b4bc6e2e9ae67cb7d40f5e930991fba21",
"version-semver": "3.10.4",
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 new experimental fast check for PR issues. Please let us know if this bot is helpful!
PRs must add only one version and must not modify any published versions
When making any changes to a library, the version or port-version in vcpkg.json
or CONTROL
must be modified.
Error: Local changes detected for nlohmann-json but no changes to version or port version.
-- Version: 3.10.4
-- Old SHA: f948131b4bc6e2e9ae67cb7d40f5e930991fba21
-- New SHA: 4c6c6eeb8001078b424e858b49bd37e37a3990e3
-- Did you remember to update the version or port version?
-- Pass `--overwrite-version` to bypass this check.
***No files were updated.***
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout 1acb3e1999ee7b9f1e161b4f0937359e01c333e0 -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/n-/nlohmann-json.json b/versions/n-/nlohmann-json.json
index bd9d883..29cfd19 100644
--- a/versions/n-/nlohmann-json.json
+++ b/versions/n-/nlohmann-json.json
@@ -1,10 +1,5 @@
{
"versions": [
- {
- "git-tree": "4c6c6eeb8001078b424e858b49bd37e37a3990e3",
- "version-semver": "3.10.4",
- "port-version": 1
- },
{
"git-tree": "f948131b4bc6e2e9ae67cb7d40f5e930991fba21",
"version-semver": "3.10.4",
AFAIU this feature is not additive but removes capabilities. You cannot first install a port which requests the feature and then another port which is not ready for it. (Add a first port which requires it here, and suddenly CI sees many failing ports.) Maybe it is doable with an additive But there is still some risk of behavioural changes at runtime due to actual conversions changing. |
@dg0yt That makes sense. I was thinking about this from the angle of engaging in beta or preview functionality given that the maintainers of nlohmann json are indicating that this may be the default behaviour in the next major version of the library. I can appreciate that there is some risk here. Let me know if you think there is a way forward; otherwise, I'll close the PR. |
This would be a use case for boolean options in #22216 |
How would this solve the problem here? Features are hardly different from boolean options. #22216 (comment) |
@autoantwort It's not clear to me that using boolean options would solve the problem that @dg0yt raised. If some project depends on If my understanding is correct, vcpkg wants to maintain a self-consistent registry where these types of failures don't happen. I guess that puts the onus on port maintainers to patch packages that depend on existing ports to work with whatever build flags have been selected for the dependencies. I suppose that means that for this type of change, I shouldn't be introducing a new feature at all. I should just hardcode the flag and then find all the ports that depend on |
ports/nlohmann-json/portfile.cmake
Outdated
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
INVERTED_FEATURES | ||
disable-implicit-conversions JSON_ImplicitConversions | ||
) | ||
|
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.
Clearly, this doesn't work as a feature; we want features to be additive, and this is a breaking change.
I think the best thing to do here is to make it a triplet setting; something like:
if(NOT DEFINED nlohmann-json_IMPLICIT_CONVERSIONS)
set(nlohmann-json_IMPLICIT_CONVERSIONS ON)
endif()
and then pass it to vcpkg_cmake_configure
as:
OPTIONS
...
"-DJSON_ImplicitConversions=${nlohmann-json_IMPLICIT_CONVERSIONS}"
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, that sounds like a better solution - thanks! Is there anywhere I should document that this triplet setting exists in case anyone else wants to use 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.
@strega-nil for opinion
There's docs/users/triplets.md
but I'm not in favor of adding port-specific documentation to it. As far as I'm aware, this would be the first variable of its kind and it makes sense for it to be documented inside the port (maybe adding a readme.md
file?).
Exactly, instead of failing at compile time or run time it would fail at resolution time. Imho that is a lot better. If you now use a triplet variable for that, you have the same negative effects as when you use a feature. And you use some magic triplet var and not a option specified in the vcpkg.json that you can simply set as a user without writing a custom triplet for every target triplet. |
@autoantwort I agree that failing at package resolution time is preferred over failing at compile time or runtime. I also agree that my initial idea of implementing this as a feature won't work. All that being said, I could imagine someone being frustrated because they are trying to depend on two libraries, libA and libB, that both depend on nlohmann-json but each specify a different value for the implicit conversion option. There's no way to reconcile the situation; the person trying to use vcpkg will be stuck. My interpretation of vcpkg's stance on this situation is that they'd prefer the port maintainers of libA and libB to deal with this problem via patches. That way vcpkg can provide a cohesive environment where port consumers can never get stuck with an unsatisfiable dependency tree. @strega-nil-ms is my interpretation correct? I don't mind using a triplet variable for this. It's on me to verify things work if I use it. My only question is where I'd document that the triplet variable exists so others can use it if they want. |
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 have modified or added at least one vcpkg.json where a "license" field is missing.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nlohmann-json/vcpkg.json
Valid values for the license field are listed at https://spdx.org/licenses/
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 have modified or added at least one vcpkg.json where a "license" field is missing.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nlohmann-json/vcpkg.json
Valid values for the license field are listed at https://spdx.org/licenses/
This triplet variable can be documented as part of a
Typically, ports that override usage will have a replacement portfile.cmake file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${port}") usage
|
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 have modified or added at least one vcpkg.json where a "license" field is missing.
If you feel able to do so, please consider adding a "license" field to the following files:
ports/nlohmann-json/vcpkg.json
Valid values for the license field can be found in the documentation
usage tells you one variable, then the portfile internally checks another one... |
@cenit Whoops, that was a copy-paste error on my part. Will push a fix. |
* master: (103 commits) [lmdb] don't use msvc parameters with non-msvc compiler (microsoft#23653) Fix <version> of Python in vcpkgTools.xml (microsoft#23751) [sciter] escape quotes (microsoft#23752) [fuzzylite] Fix Linux build (microsoft#23658) [cpp-redis] Fix ‘sleep_for’ is not a member of ‘std::this_thread’ (microsoft#23762) [nlohmann-json] Fix usage text (microsoft#23749) [fontconfig] Do not create symlinks (microsoft#23735) (microsoft#23736) [winsparkle] Fix header file and debug path (microsoft#23739) [arb] Support dynamic build (microsoft#23743) [aws-sdk-cpp] update to 1.9.220 (microsoft#23729) Fix the VS2022 'unstable' queues. (microsoft#23742) [xmlsec] Bump to 1.2.33 (microsoft#23733) [unicorn] update to latest version v1.0.3 (microsoft#23745) [libpq] Update version to 14.1 2 (microsoft#22516) [libnoise] Export CMake files (microsoft#23682) [vcpk-ci] Trigger some test ports from vcpkg.cmake changes (microsoft#23430) [nlohmann-json] Add option to control implicit conversions behaviour (microsoft#22409) [libjuice] Update to 0.9.8 (microsoft#23153) [libgeotiff] Update to 1.7.1 (microsoft#23446) [minizip-ng] Updated minizip version and fixed windows build for previous version (microsoft#23684) ...
This adds an inverse feature
disable-implicit-conversions
to the nlohmann-json port as described in the associated issue (#22408)What does your PR fix?
Fixes #22408
Which triplets are supported/not supported? Have you updated the CI baseline?
No changes required
Does your PR follow the maintainer guide?
Yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --all
and committed the result?Yes