diff --git a/recipes/asset-canister/recipe.hbs b/recipes/asset-canister/recipe.hbs index 012a4e5..fc392eb 100644 --- a/recipes/asset-canister/recipe.hbs +++ b/recipes/asset-canister/recipe.hbs @@ -8,6 +8,12 @@ build: steps: + {{#if metadata}} + - type: script + commands: + - sh -c 'command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; }' + {{/if}} + {{#if build}} {{! Execute frontend build command(s) first }} - type: script @@ -28,7 +34,6 @@ build: - type: script commands: {{#each metadata}} - - sh -c 'command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; }' - sh -c 'ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "{{ name }}" -d "{{ value }}" --keep-name-section' {{/each}} {{/if}} diff --git a/recipes/motoko/recipe.hbs b/recipes/motoko/recipe.hbs index 7ab4ee7..9508fac 100644 --- a/recipes/motoko/recipe.hbs +++ b/recipes/motoko/recipe.hbs @@ -8,14 +8,21 @@ build: steps: + # Check that required commands exist - type: script commands: - sh -c 'command -v mops >/dev/null 2>&1 || { echo >&2 "'mops' not found on path. To install Mops, see https://mops.one/docs/install.\n"; exit 1; }' + - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } + {{#if compress }} + - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } + {{/if}} + + - type: script + commands: - sh -c '$(mops toolchain bin moc) "{{ main }}" {{#if args}}{{ args }} {{/if}}{{#if candid}}--omit-metadata{{else}}--public-metadata{{/if}} candid:service $(mops sources) -o "$ICP_WASM_OUTPUT_PATH"' - type: script commands: - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } - sh -c 'ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "moc:version" -d "$($(mops toolchain bin moc) --version)" --keep-name-section' - type: script @@ -33,14 +40,12 @@ build: {{#if shrink}} - type: script commands: - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" shrink --keep-name-section {{/if}} {{#if compress }} - type: script commands: - - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } - gzip --no-name "$ICP_WASM_OUTPUT_PATH" - mv "${ICP_WASM_OUTPUT_PATH}.gz" "$ICP_WASM_OUTPUT_PATH" {{/if}} diff --git a/recipes/prebuilt/recipe.hbs b/recipes/prebuilt/recipe.hbs index 2aca2dd..2cd44e7 100644 --- a/recipes/prebuilt/recipe.hbs +++ b/recipes/prebuilt/recipe.hbs @@ -9,6 +9,19 @@ build: steps: + - type: script + commands: + - echo "Checking pre-requisites" + {{#if metadata}} + - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } + {{/if}} + {{#if shrink}} + - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } + {{/if}} + {{#if compress}} + - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } + {{/if}} + - type: pre-built path: {{ path }} {{#if sha256 }} @@ -19,7 +32,6 @@ build: - type: script commands: {{#each metadata}} - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "{{ name }}" -d "{{ value }}" --keep-name-section {{/each}} {{/if}} @@ -27,14 +39,12 @@ build: {{#if shrink}} - type: script commands: - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" shrink --keep-name-section {{/if}} {{#if compress}} - type: script commands: - - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } - gzip --no-name "$ICP_WASM_OUTPUT_PATH" - mv "${ICP_WASM_OUTPUT_PATH}.gz" "$ICP_WASM_OUTPUT_PATH" {{/if}} diff --git a/recipes/rust/recipe.hbs b/recipes/rust/recipe.hbs index 51552c3..d5f36e4 100644 --- a/recipes/rust/recipe.hbs +++ b/recipes/rust/recipe.hbs @@ -7,6 +7,16 @@ build: steps: + - type: script + commands: + - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 'ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n'; exit 1; } + {{#unless candid}} + - command -v candid-extractor >/dev/null 2>&1 || { echo >&2 'candid-extractor not found. Run `cargo install candid-extractor` to install it.'; exit 1; } + {{/unless}} + {{#if compress }} + - command -v gzip >/dev/null 2>&1 || { echo >&2 "gzip not found. Please install gzip to compress build output. \n"; exit 1; } + {{/if}} + - type: script commands: - cargo build --package {{ package }} --target wasm32-unknown-unknown --release @@ -14,13 +24,11 @@ build: - type: script commands: - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 'ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n'; exit 1; } - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "cargo:version" -d "$(cargo --version)" --keep-name-section - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "template:type" -d "rust" --keep-name-section {{#if candid}} - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "candid:service" -f '{{ candid }}' -v public --keep-name-section {{else}} - - command -v candid-extractor >/dev/null 2>&1 || { echo >&2 'candid-extractor not found. Run `cargo install candid-extractor` to install it.'; exit 1; } - did="$(mktemp)"; candid-extractor "$ICP_WASM_OUTPUT_PATH" >"$did" && ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" metadata "candid:service" -f "$did" -v public --keep-name-section {{/if}} {{#if metadata}} @@ -32,7 +40,6 @@ build: {{#if shrink}} - type: script commands: - - command -v ic-wasm >/dev/null 2>&1 || { echo >&2 "ic-wasm not found. To install ic-wasm, see https://github.com/dfinity/ic-wasm \n"; exit 1; } - ic-wasm "$ICP_WASM_OUTPUT_PATH" -o "${ICP_WASM_OUTPUT_PATH}" shrink --keep-name-section {{/if}}