-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/cargo/serde-1.0.210
- Loading branch information
Showing
10 changed files
with
68 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
did_file_location_from_cargo() { | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path | sub("Cargo.toml";"\($v).did")' | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path | sub("Cargo.toml";"\($v).did")' | ||
} | ||
cargo_manifest_path() { | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path")' | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path")' | ||
} | ||
did_file_location_from_dfx_json() { | ||
# Warning: Does no _- conversion. | ||
jq -r --arg v "$1" '.canisters[$v].candid' dfx.json | ||
# Warning: Does no _- conversion. | ||
jq -r --arg v "$1" '.canisters[$v].candid' dfx.json | ||
} | ||
|
||
function generate_did() { | ||
local canister=$1 | ||
echo "Deriving candid file from Rust for $canister" | ||
#local manifest_path="$(cargo_manifest_path "$canister")" | ||
#local candid_file="${manifest_path%Cargo.toml}$canister.did" | ||
local candid_file="$(did_file_location_from_dfx_json "$canister")" | ||
local canister=$1 | ||
echo "Deriving candid file from Rust for $canister" | ||
#local manifest_path="$(cargo_manifest_path "$canister")" | ||
#local candid_file="${manifest_path%Cargo.toml}$canister.did" | ||
local candid_file="$(did_file_location_from_dfx_json "$canister")" | ||
|
||
test -e "target/wasm32-unknown-unknown/release/$canister.wasm" || | ||
cargo build -p "$canister" \ | ||
--target wasm32-unknown-unknown \ | ||
--release --package "$canister" | ||
test -e "target/wasm32-unknown-unknown/release/$canister.wasm" || | ||
cargo build -p "$canister" \ | ||
--target wasm32-unknown-unknown \ | ||
--release --package "$canister" | ||
|
||
# cargo install candid-extractor | ||
candid-extractor "target/wasm32-unknown-unknown/release/$canister.wasm" >"$candid_file" | ||
echo "Written: $candid_file" | ||
# cargo install candid-extractor | ||
candid-extractor "target/wasm32-unknown-unknown/release/$canister.wasm" >"$candid_file" | ||
echo "Written: $candid_file" | ||
} | ||
|
||
CANISTERS=(example_app_backend example_paid_service) | ||
|
||
for canister in ${CANISTERS[@]}; do | ||
generate_did "$canister" | ||
generate_did "$canister" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
print_help() { | ||
echo "Runs rust unit tests." | ||
} | ||
|
||
[[ "${1:-}" != "--help" ]] || print_help | ||
|
||
cargo test --lib --bins "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters