Skip to content

Commit

Permalink
[new package] wasmtime 25.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ognevny authored Oct 6, 2024
1 parent 6b1cd4a commit 2ec9c44
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions mingw-w64-wasmtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/wasmtime
116 changes: 116 additions & 0 deletions mingw-w64-wasmtime/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Maintainer: Maksim Bondarenkov <[email protected]>

_realname=wasmtime
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-lib${_realname}")
pkgver=25.0.1
pkgrel=1
pkgdesc="A fast and secure runtime for WebAssembly (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://wasmtime.dev'
msys2_repository_url='https://github.com/bytecodealliance/wasmtime'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-zstd")
makedepends=("${MINGW_PACKAGE_PREFIX}-rust"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-pkgconf"
"${MINGW_PACKAGE_PREFIX}-zstd"
'git')
source=("git+${msys2_repository_url}.git#tag=v${pkgver}"
"zstd-sys.tar.gz::https://crates.io/api/v1/crates/zstd-sys/2.0.9+zstd.1.5.5/download"
"zstd-sys-remove-statik.patch")
sha256sums=('56a854f707095fdb718a15dc241a5e88fae1ed85e3d4922688fb5af7e03898f1'
'9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656'
'48f4900ceb02d3aaf9a1020f33d56629156e96759f456c0e7ca18bfcf910767b')

prepare() {
cd "${_realname}"

git submodule update --init --recursive
patch -d ../zstd-sys-2.0.9+zstd.1.5.5 -i ../zstd-sys-remove-statik.patch
cat >> Cargo.toml <<END
[patch.crates-io]
zstd-sys = { path = "../zstd-sys-2.0.9+zstd.1.5.5" }
END

cargo update -p zstd-sys
cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
export ZSTD_SYS_USE_PKG_CONFIG=1
export WINAPI_NO_BUNDLED_LIBRARIES=1
export MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX="

cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
-DBUILD_SHARED_LIBS=OFF \
-DWASMTIME_FASTEST_RUNTIME=ON \
-DWASMTIME_TARGET="$(rustc -vV | sed -n 's/host: //p')" \
-S "${_realname}/crates/c-api" \
-B "build-${MSYSTEM}-static"

cmake --build "build-${MSYSTEM}-static"

cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
-DBUILD_SHARED_LIBS=ON \
-DWASMTIME_FASTEST_RUNTIME=ON \
-DWASMTIME_TARGET="$(rustc -vV | sed -n 's/host: //p')" \
-S "${_realname}/crates/c-api" \
-B "build-${MSYSTEM}-shared"

cmake --build "build-${MSYSTEM}-shared"

cargo build \
--frozen \
--profile fastest-runtime \
-p wasmtime-cli \
--manifest-path "${_realname}/Cargo.toml"
}

check() {
cd "${_realname}"

cargo test --frozen --profile fastest-runtime
}

package_wasmtime() {
cd "${_realname}"

cargo install \
--offline \
--no-track \
--frozen \
--path . \
--root "${pkgdir}${MINGW_PREFIX}" \
--profile fastest-runtime

install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

package_libwasmtime() {
pkgdesc+=' (C-API)'

DESTDIR="${pkgdir}" cmake --install "build-${MSYSTEM}-static"
DESTDIR="${pkgdir}" cmake --install "build-${MSYSTEM}-shared"
install -d "${pkgdir}${MINGW_PREFIX}/bin"

mv "${pkgdir}${MINGW_PREFIX}/lib/wasmtime.dll" "${pkgdir}${MINGW_PREFIX}/bin/wasmtime.dll"
install -Dm644 "${_realname}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

# vim: set ft=bash :

# generate wrappers
for _name in "${pkgname[@]}"; do
_short="package_${_name#${MINGW_PACKAGE_PREFIX}-}"
_func="$(declare -f "${_short}")"
eval "${_func/#${_short}/package_${_name}}"
done
10 changes: 10 additions & 0 deletions mingw-w64-wasmtime/zstd-sys-remove-statik.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/build.rs
+++ b/build.rs
@@ -41,7 +41,6 @@ fn generate_bindings(_: Vec<&str>, _: Vec<PathBuf>) {}

fn pkg_config() -> (Vec<&'static str>, Vec<PathBuf>) {
let library = pkg_config::Config::new()
- .statik(true)
.cargo_metadata(!cfg!(feature = "non-cargo"))
.probe("libzstd")
.expect("Can't probe for zstd in pkg-config");

0 comments on commit 2ec9c44

Please sign in to comment.