This repository has been archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code seems good, but this has to be explicit: It is stated in documentation, that root package features are not being checked. So I think it would be great to state somewhere (better |
it is stated in the macro docs |
kroist
approved these changes
Feb 21, 2024
# Conflicts: # Cargo.lock # Cargo.toml
deuszx
reviewed
Mar 5, 2024
deuszx
approved these changes
Mar 5, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When specifying a contract dependency with some required features (apart from
ink-as-dependency
), e.g.:using either
#[drink::contract_bundle_provider]
or#[drink::test]
used to end up with some linking error, because actually suchpsp22
would be built without thecontract
feature.Solution in this PR
After ~2h of playing with the output from
cargo metadata
and dependency resolution, I went for the easiest, yet not so accurate approach:ink-as-dependecy
feature present) I take all the features that were turned on on any resolution path. This means that even if some other dependency would depend on such PSP22 with a featurenot-related-to-contracts
(while our main contract wouldn't), thenot-related-to-contracts
feature is included; the only exception is thestd
feature, which is always included on a certain dependency resolution path.Of course, there are cases where this approach is not correct, but I really don't see any point in wasting more time now, at least somebody actually will have the problem.
Ad 1.: I think that it is now not possible to fetch the
--features
argument passed tocargo
in a procedural macro. One can inspect all presentCARGO_FEATURE_<name>
env variables (https://doc.rust-lang.org/cargo/reference/environment-variables.html), but then recreating original name (modulo underscores, dashes, capitalization) is hehe.