Skip to content

Commit

Permalink
cli: Warn if anchor-spl/idl-build is missing (#3133)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Jul 29, 2024
1 parent fb7ea68 commit 895f018
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 21 additions & 1 deletion cli/src/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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(())
}

0 comments on commit 895f018

Please sign in to comment.