Skip to content

Commit

Permalink
Merge branch 'automerge:main' into migue/automerge-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangel-dev authored Jun 7, 2024
2 parents 0f3aa34 + 830dd77 commit f2caece
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
- uses: swiftwasm/setup-swiftwasm@v1
with:
swift-version: "wasm-5.9.1-RELEASE"
- run: cargo build --manifest-path rust/Cargo.toml --target wasm32-wasi --release
#- run: cargo build --manifest-path rust/Cargo.toml --target wasm32-wasi --release
- run: scripts/ci/wasi-regen-swift.sh
- uses: actions/upload-artifact@v4
with:
name: libuniffi_automerge-wasm32-unknown-wasi.a
Expand Down
36 changes: 36 additions & 0 deletions scripts/ci/wasi-regen-swift.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# This script is strictly for CI usage to support pull requests that update
# the Rust core library. The headers need to be regenerated for the WASI build
# explicitly, which is part of the release process for general purposes, but
# may need an explicit one-off to correctly test a local build in CI.

# bash "strict" mode
# https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425
set -euxo pipefail

THIS_SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
RUST_FOLDER="$THIS_SCRIPT_DIR/../../rust"

FRAMEWORK_NAME="automergeFFI"

SWIFT_FOLDER="$THIS_SCRIPT_DIR/../../AutomergeUniffi"
cargo_build="cargo build --manifest-path ${RUST_FOLDER}/Cargo.toml"

mkdir -p "${SWIFT_FOLDER}"

echo "▸ Generate Swift Scaffolding Code"
cargo run --manifest-path "$RUST_FOLDER/Cargo.toml" \
--features=uniffi/cli \
--bin uniffi-bindgen generate \
"$RUST_FOLDER/src/automerge.udl" \
--language swift \
--out-dir "${SWIFT_FOLDER}"

echo "▸ Building for wasm32-wasi"
$cargo_build --target wasm32-wasi --locked --release

# copies the generated header from AutomergeUniffi/automergeFFI.h to
# Sources/_CAutomergeUniffi/include/automergeFFI.h within the project
cp "${SWIFT_FOLDER}/automergeFFI.h" "${SWIFT_FOLDER}/../Sources/_CAutomergeUniffi/include"
cp "${SWIFT_FOLDER}/automergeFFI.modulemap" "${SWIFT_FOLDER}/../Sources/_CAutomergeUniffi/include/module.modulemap"

0 comments on commit f2caece

Please sign in to comment.