Skip to content

Commit

Permalink
build: ic-wasm --keep-name-section (#721)
Browse files Browse the repository at this point in the history
* build: ic-wasm --keep-name-section

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>

* build: --keep-name-section in docker as well

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>

---------

Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
  • Loading branch information
peterpeterparker committed Sep 21, 2024
1 parent f7bc3af commit 2b6e2a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,22 @@ function build_canister() {
ic-wasm \
"$CARGO_TARGET_DIR/$TARGET/release/$canister.wasm" \
-o "./$canister.wasm" \
shrink
shrink \
--keep-name-section

# adds the content of $canister.did to the `icp:public candid:service` custom section of the public metadata in the wasm
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata candid:service -f "$SRC_DIR/$canister.did" -v public
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata candid:service -f "$SRC_DIR/$canister.did" -v public --keep-name-section

if [ "$canister" == "satellite" ]
then
# add the type of build "stock" to the satellite. This way, we can identify whether it's the standard canister ("stock") or a custom build ("extended") of the developer.
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata juno:build -d "stock" -v public
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata juno:build -d "stock" -v public --keep-name-section
fi

if [ "$canister" == "satellite" ] || [ "$canister" == "console" ];
then
# indicate support for certificate version 1 and 2 in the canister metadata
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata supported_certificate_versions -d "1,2" -v public
ic-wasm "$canister.wasm" -o "$canister.wasm" metadata supported_certificate_versions -d "1,2" -v public --keep-name-section
fi

gzip --no-name --force "./$canister.wasm"
Expand Down
9 changes: 5 additions & 4 deletions scripts/cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ candid-extractor "${RELEASE_DIR}/${WASM_MODULE}" > "${DID_DIR}/${WASM_MODULE}.di
ic-wasm \
"${RELEASE_DIR}/${WASM_MODULE}" \
-o "${WASM_DIR}/${WASM_MODULE}" \
shrink
shrink \
--keep-name-section

# adds the content of did to the `icp:public candid:service` custom section of the public metadata in the wasm
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata candid:service -f "${DID_DIR}/${WASM_MODULE}.did" -v public
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata candid:service -f "${DID_DIR}/${WASM_MODULE}.did" -v public --keep-name-section

if [ "${WASM_MODULE}" == "satellite" ]
then
# add the type of build "stock" to the satellite. This way, we can identify whether it's the standard canister ("stock") or a custom build ("extended") of the developer.
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata juno:build -d "stock" -v public
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata juno:build -d "stock" -v public --keep-name-section
fi

if [ "${MODULE}" == "satellite" ] || [ "${MODULE}" == "console" ];
then
# indicate support for certificate version 1 and 2 in the canister metadata
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata supported_certificate_versions -d "1,2" -v public
ic-wasm "${WASM_DIR}/${WASM_MODULE}" -o "${WASM_DIR}/${WASM_MODULE}" metadata supported_certificate_versions -d "1,2" -v public --keep-name-section
fi

gzip -c --no-name --force "${WASM_DIR}/${WASM_MODULE}" > "${DEPLOY_DIR}/${WASM_MODULE}.tmp.gz"
Expand Down

0 comments on commit 2b6e2a8

Please sign in to comment.