Skip to content

Commit

Permalink
idl: Fix generation with recursive external types (#2946)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos authored May 7, 2024
1 parent 970cd23 commit 128e937
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- ts: Fix incorrect `maxSupportedTransactionVersion` in `AnchorProvider.send*()` methods ([#2922](https://github.com/coral-xyz/anchor/pull/2922)).
- cli: Use npm's configured default license for new projects made with `anchor init` ([#2929](https://github.com/coral-xyz/anchor/pull/2929)).
- cli: add filename to 'Unable to read keypair file' errors ([#2932](https://github.com/coral-xyz/anchor/pull/2932)).
- idl: Fix path resolution of the `Cargo.lock` of the project when generating idls for external types ([#2946](https://github.com/coral-xyz/anchor/pull/2946)).

### Breaking

Expand Down
1 change: 1 addition & 0 deletions idl/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ fn build(program_path: &Path, resolution: bool, no_docs: bool) -> Result<Idl> {
"ANCHOR_IDL_BUILD_RESOLUTION",
if resolution { "TRUE" } else { "FALSE" },
)
.env("ANCHOR_IDL_BUILD_PROGRAM_PATH", program_path)
.env("RUSTFLAGS", "--cfg procmacro2_semver_exempt")
.current_dir(program_path)
.stderr(Stdio::inherit())
Expand Down
5 changes: 3 additions & 2 deletions lang/syn/src/idl/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ pub fn get_external_type(name: &str, path: impl AsRef<Path>) -> Result<Option<sy
.ok_or_else(|| anyhow!("`{name}` not found in use statements"))?;

// Get crate name and version from lock file
let lib_path = find_path("lib.rs", path)?;
let lock_path = find_path("Cargo.lock", lib_path)?;
let program_path =
std::env::var("ANCHOR_IDL_BUILD_PROGRAM_PATH").expect("Failed to get program path");
let lock_path = find_path("Cargo.lock", program_path)?;
let lock_file = parse_lock_file(lock_path)?;
let registry_path = get_registry_path()?;

Expand Down

0 comments on commit 128e937

Please sign in to comment.