Skip to content

Commit

Permalink
feat: Re-generate bindings if canister id or candid path change (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 authored Apr 10, 2024
1 parent a7650a2 commit 681008a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ic-cdk-bindgen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

- Re-generate bindings if the canister ids changed (e.g. when switching networks) or when the path to the candid file of a dependency changed.

## [0.1.3] - 2024-02-27

- Resolve CANISTER_CANDID_PATH and CANISTER_ID from standardized environment variables (uppercase canister names).
Expand Down
4 changes: 4 additions & 0 deletions src/ic-cdk-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fn resolve_candid_path_and_canister_id(canister_name: &str) -> (PathBuf, Princip

let candid_path_var_name = format!("CANISTER_CANDID_PATH_{}", canister_name_upper);
let candid_path_var_name_legacy = format!("CANISTER_CANDID_PATH_{}", canister_name);
println!("cargo:rerun-if-env-changed={candid_path_var_name}");
println!("cargo:rerun-if-env-changed={candid_path_var_name_legacy}");

let candid_path_str = if let Ok(candid_path_str) = env::var(&candid_path_var_name) {
candid_path_str
Expand All @@ -69,6 +71,8 @@ fn resolve_candid_path_and_canister_id(canister_name: &str) -> (PathBuf, Princip

let canister_id_var_name = format!("CANISTER_ID_{}", canister_name_upper);
let canister_id_var_name_legacy = format!("CANISTER_ID_{}", canister_name);
println!("cargo:rerun-if-env-changed={canister_id_var_name}");
println!("cargo:rerun-if-env-changed={canister_id_var_name_legacy}");
let canister_id_str = if let Ok(canister_id_str) = env::var(&canister_id_var_name) {
canister_id_str
} else if let Ok(canister_id_str) = env::var(&canister_id_var_name_legacy) {
Expand Down

0 comments on commit 681008a

Please sign in to comment.