cli: Warn if `anchor-spl/idl-build` is missing (#3133)

This commit is contained in:
acheron 2024-07-29 22:55:06 +02:00 committed by GitHub
parent fb7ea68c0d
commit 895f01865a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -27,6 +27,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- client: Support non-8-byte discriminators ([#3125](https://github.com/coral-xyz/anchor/pull/3125)).
- spl: Add `withdraw_withheld_tokens_from_accounts` instruction ([#3128]([https://github.com/coral-xyz/anchor/pull/3128)).
- ts: Add optional `wallet` property to the `Provider` interface ([#3130](https://github.com/coral-xyz/anchor/pull/3130)).
- cli: Warn if `anchor-spl/idl-build` is missing ([#3133](https://github.com/coral-xyz/anchor/pull/3133)).
### Fixes

View File

@ -85,7 +85,10 @@ pub fn check_anchor_version(cfg: &WithPath<Config>) -> Result<()> {
///
/// **Note:** The check expects the current directory to be a program directory.
pub fn check_idl_build_feature() -> Result<()> {
Manifest::from_path("Cargo.toml")?
let manifest = Manifest::from_path("Cargo.toml")?;
// Check if `idl-build` is enabled by default
manifest
.dependencies
.iter()
.filter(|(_, dep)| dep.req_features().contains(&"idl-build".into()))
@ -100,5 +103,22 @@ pub fn check_idl_build_feature() -> Result<()> {
)
});
// Check `anchor-spl`'s `idl-build` feature
manifest
.dependencies
.get("anchor-spl")
.and_then(|_| manifest.features.get("idl-build"))
.map(|feature_list| !feature_list.contains(&"anchor-spl/idl-build".into()))
.unwrap_or_default()
.then(|| {
eprintln!(
"WARNING: `idl-build` feature of `anchor-spl` is not enabled. \
This is likely to result in cryptic compile errors.\n\n\t\
To solve, add `anchor-spl/idl-build` to the `idl-build` feature list:\n\n\t\
[features]\n\t\
idl-build = [\"anchor-spl/idl-build\", ...]\n"
)
});
Ok(())
}