Skip to content

Commit 1a18fe5

Browse files
committed
Update build process to use candid-extractor and add cdylib crate types
1 parent da969bf commit 1a18fe5

File tree

28 files changed

+119
-78
lines changed

28 files changed

+119
-78
lines changed

ic-canister/tests/canister-a/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "canister-a"
33
version.workspace = true
44
edition.workspace = true
55

6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
69
[features]
710
default = []
811
export-api = []

ic-canister/tests/canister-a/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ use ic_exports::candid::{CandidType, Deserialize, Principal};
88
use ic_storage::stable::Versioned;
99
use ic_storage::IcStorage;
1010

11+
#[ic_canister::export_candid]
12+
pub fn idl() -> String {
13+
let idl = CanisterAImpl::get_idl();
14+
candid::pretty::candid::compile(&idl.env.env, &Some(idl.actor))
15+
}
16+
1117
#[derive(Default, CandidType, Deserialize, IcStorage)]
1218
pub struct StateA {
1319
counter: u32,

ic-canister/tests/canister-a/src/main.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

ic-canister/tests/canister-b/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "canister-b"
33
version.workspace = true
44
edition.workspace = true
55

6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
69
[features]
710
default = []
811
export-api = []

ic-canister/tests/canister-b/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ use ic_canister::{
99
use ic_exports::candid::{CandidType, Deserialize, Principal};
1010
use ic_storage::IcStorage;
1111

12+
// #[ic_canister::export_candid]
13+
pub fn canister_b_idl() -> String {
14+
use ic_canister::Idl;
15+
16+
let canister_b_idl = generate_idl!();
17+
let mut canister_a_idl = <CanisterB as CanisterA>::get_idl();
18+
canister_a_idl.merge(&canister_b_idl);
19+
20+
candid::pretty::candid::compile(&canister_a_idl.env.env, &Some(canister_a_idl.actor))
21+
}
22+
1223
#[derive(IcStorage, CandidType, Deserialize)]
1324
struct StateB {
1425
canister_a: Principal,
@@ -108,16 +119,6 @@ impl CanisterA for CanisterB {
108119
}
109120
}
110121

111-
pub fn idl() -> String {
112-
use ic_canister::Idl;
113-
114-
let canister_b_idl = generate_idl!();
115-
let mut canister_a_idl = <CanisterB as CanisterA>::get_idl();
116-
canister_a_idl.merge(&canister_b_idl);
117-
118-
candid::pretty::candid::compile(&canister_a_idl.env.env, &Some(canister_a_idl.actor))
119-
}
120-
121122
#[cfg(test)]
122123
mod tests {
123124
use ic_exports::ic_kit::mock_principals::alice;

ic-canister/tests/canister-b/src/main.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

ic-canister/tests/canister-c/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "canister-c"
33
version.workspace = true
44
edition.workspace = true
55

6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
69
[features]
710
default = []
811
export-api = []

ic-canister/tests/canister-c/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl PreUpdate for CanisterC {
5353
}
5454
}
5555

56+
#[ic_canister::export_candid]
5657
pub fn idl() -> String {
5758
use ic_canister::Idl;
5859

ic-canister/tests/canister-c/src/main.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

ic-canister/tests/canister-d/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "canister-d"
33
version.workspace = true
44
edition.workspace = true
55

6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
69
[features]
710
default = []
811
export-api = []

0 commit comments

Comments
 (0)