Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/actions/build_core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ inputs:
CARGO_PROFILE:
description: "Cargo profile name to use for cargo cache key"
required: false
default: 'release'
default: "release"
CORE_WASM:
description: "Whether to build core.wasm and core-async.wasm, oneOf `none, build, upload`"
required: false
default: 'none'
default: "none"
TEST_CORE_WASM:
description: "Whether to build test-core.wasm and test-core-async.wasm, oneOf `none, build, upload`"
required: false
default: 'none'
default: "none"
COMLINK_WASM:
description: "Whether to build comlink.wasm, oneOf `none, build, upload`"
required: false
default: 'none'
default: "none"

runs:
using: "composite"
Expand Down Expand Up @@ -52,7 +52,7 @@ runs:
sudo apt-get install binaryen
- name: Install rust target
shell: bash
run: rustup target add wasm32-wasi
run: rustup target add wasm32-wasip1
# build and store core.wasm, core-async.wasm
- name: Run make to build core.wasm
if: ${{ inputs.CORE_WASM != 'none' }}
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ git_hooks:
## CORE ##
##########
deps_core: ${WASI_SDK_FOLDER}
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
curl https://wasmtime.dev/install.sh -sSf | bash

${CORE_DIST}: ${WASI_SDK_FOLDER} ${CORE_JS_ASSETS_MAP_STD} ${CORE_JS_ASSETS_PROFILE_VALIDATOR} ${CORE_SCHEMA_ASSETS_SECURITY_VALUES} ${CORE_SCHEMA_ASSETS_PARAMETERS_VALUES}
mkdir -p ${CORE_DIST}
touch ${CORE_DIST}

${CORE_WASM}: ${CORE_DIST}
cd core; cargo build --package oneclient_core --target wasm32-wasi ${CARGO_FLAGS}
cd core; cargo build --package oneclient_core --target wasm32-wasip1 ${CARGO_FLAGS}
@echo 'Optimizing wasm...'
wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasi/${CARGO_PROFILE}/oneclient_core.wasm --output ${CORE_WASM}
wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasip1/${CARGO_PROFILE}/oneclient_core.wasm --output ${CORE_WASM}

${TEST_CORE_WASM}: ${CORE_DIST}
cd core; cargo build --package oneclient_core --target wasm32-wasi --features "core_mock" ${CARGO_FLAGS}
cp core/target/wasm32-wasi/${CARGO_PROFILE}/oneclient_core.wasm ${TEST_CORE_WASM}
cd core; cargo build --package oneclient_core --target wasm32-wasip1 --features "core_mock" ${CARGO_FLAGS}
cp core/target/wasm32-wasip1/${CARGO_PROFILE}/oneclient_core.wasm ${TEST_CORE_WASM}

${CORE_ASYNCIFY_WASM}: ${CORE_WASM}
@echo 'Running asyncify...'
Expand All @@ -100,18 +100,18 @@ ${TEST_CORE_ASYNCIFY_WASM}: ${TEST_CORE_WASM}

${CORE_COMLINK_WASM}:
mkdir -p ${CORE_DIST}
cd core; cargo build --package comlink_wasm --target wasm32-wasi ${CARGO_FLAGS}
wasm-opt -Os ${WASM_OPT_FLAGS} core/target/wasm32-wasi/${CARGO_PROFILE}/comlink_wasm.wasm --output ${CORE_COMLINK_WASM}
cd core; cargo build --package comlink_wasm --target wasm32-wasip1 ${CARGO_FLAGS}
wasm-opt -Oz ${WASM_OPT_FLAGS} core/target/wasm32-wasip1/${CARGO_PROFILE}/comlink_wasm.wasm --output ${CORE_COMLINK_WASM}

${WASI_SDK_FOLDER}:
wget -qO - ${WASI_SDK_URL} | tar xzvf - -C core

test_core: ${WASI_SDK_FOLDER} ${CORE_JS_ASSETS_MAP_STD} ${CORE_JS_ASSETS_PROFILE_VALIDATOR} ${CORE_SCHEMA_ASSETS_SECURITY_VALUES} ${CORE_SCHEMA_ASSETS_PARAMETERS_VALUES}
cd core && cargo test -- --nocapture
cd core && cargo test

build_core: ${CORE_WASM} ${TEST_CORE_WASM} ${CORE_ASYNCIFY_WASM} ${TEST_CORE_ASYNCIFY_WASM}
build_core_json_schemas:
cd core/json_schemas && cargo build && wasmtime run --dir=. ../target/wasm32-wasi/debug/json_schemas.wasm
cd core/json_schemas && cargo build && wasmtime run --dir=. ../target/wasm32-wasip1/debug/json_schemas.wasm

${CORE_JS_ASSETS_MAP_STD}: ${MAP_STD}
mkdir -p ${CORE_JS_ASSETS}
Expand Down
4 changes: 2 additions & 2 deletions core/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ QUICKJS_WASM_SYS_WASI_SDK_PATH = { value = "wasi-sdk-20.0", relative = true }
WASMTIME_NEW_CLI = "1"

[build]
target = "wasm32-wasi"
target = "wasm32-wasip1"

[target.wasm32-wasi]
[target.wasm32-wasip1]
runner = "wasmtime"
16 changes: 12 additions & 4 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ thiserror = { version = "1" }
url = { version = "2" }
tracing = { version = "0.1" }

[profile.dev]
opt-level = 1 #

[profile.release]
opt-level = "s"
lto = true
Expand Down
1 change: 1 addition & 0 deletions core/core/src/sf_core/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub enum ProfileCacheEntryError {
}
#[derive(Debug)]
pub struct ProfileCacheEntry {
#[allow(dead_code)]
pub profile: String, // TODO: parsed so we can extract the version
pub content_hash: String,
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-a-core/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def dockerfile_template(
cargo_profile = cargo_profile.replace("\n", "\\n").replace('"', '\\"')

if wasm_opt_flags != "":
post_process = f"{OPT_BINARYEN}/bin/wasm-opt {wasm_opt_flags} {CARGO_TARGET_DIR}/wasm32-wasi/build-a-core/oneclient_core.wasm --output /opt/build-a-core/core.wasm"
post_process = f"{OPT_BINARYEN}/bin/wasm-opt {wasm_opt_flags} {CARGO_TARGET_DIR}/wasm32-wasip1/build-a-core/oneclient_core.wasm --output /opt/build-a-core/core.wasm"
else:
post_process = f"cp {CARGO_TARGET_DIR}/wasm32-wasi/build-a-core/oneclient_core.wasm /opt/build-a-core/core.wasm"
post_process = f"cp {CARGO_TARGET_DIR}/wasm32-wasip1/build-a-core/oneclient_core.wasm /opt/build-a-core/core.wasm"

return f"""
FROM debian:bookworm as wasi-sdk-builder
Expand Down Expand Up @@ -68,7 +68,7 @@ def dockerfile_template(
apt clean
rm -rf /var/lib/apt/lists/*
EOF
RUN rustup default {toolchain_version} && rustup component add rust-src && rustup target add wasm32-wasi
RUN rustup default {toolchain_version} && rustup component add rust-src && rustup target add wasm32-wasip1

WORKDIR /opt/build-a-core
RUN git clone https://github.com/superfaceai/one-sdk.git . && git checkout {core_ref}
Expand Down Expand Up @@ -97,7 +97,7 @@ def dockerfile_template(
ENV CARGO_HOME=/var/cache/cargo
ENV CARGO_TARGET_DIR={CARGO_TARGET_DIR}
RUN echo "{cargo_profile}" >>Cargo.toml
RUN --mount=type=cache,target=/var/cache/cargo cargo build --target wasm32-wasi --package oneclient_core --profile build-a-core {build_std_flags}
RUN --mount=type=cache,target=/var/cache/cargo cargo build --target wasm32-wasip1 --package oneclient_core --profile build-a-core {build_std_flags}

COPY --from=binaryen-builder /opt/binaryen/bin {OPT_BINARYEN}/bin
COPY --from=binaryen-builder /opt/binaryen/lib {OPT_BINARYEN}/lib
Expand Down
Loading