-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_did.sh
31 lines (25 loc) · 968 Bytes
/
build_did.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! /bin/bash
package="dvote_backend"
did_file="src/$package/$package.did"
# install rustup and cargo
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi
if ! command -v cargo &>/dev/null; then
source "$HOME/.cargo/env"
fi
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown \
--release \
--package "$package" --features "ic-cdk/wasi"
# curl https://wasmtime.dev/install.sh -sSf | bash
wasmtime "target/wasm32-unknown-unknown/release/$package.wasm" >"$did_file"
printf "\n\n// https://github.com/dfinity/candid/blob/master/spec/Candid.md" >>$did_file
cat "$did_file"
cargo build --target wasm32-unknown-unknown \
--release \
--package "$package"
# cargo install ic-wasm
ic-wasm "target/wasm32-unknown-unknown/release/$package.wasm" \
-o "target/wasm32-unknown-unknown/release/$package.wasm" \
metadata candid:service -v public -f "$did_file"