Skip to content

Commit

Permalink
attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 20, 2023
1 parent 1aba155 commit b93c3c9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 35 deletions.
25 changes: 3 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,31 +166,12 @@ jobs:
with:
name: ${{ matrix.build }}

- name: Configure minimal build
if: matrix.min
run: |
rustup component add rust-src
echo CARGO_PROFILE_RELEASE_STRIP=debuginfo >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_OPT_LEVEL=s >> $GITHUB_ENV
echo RUSTFLAGS=-Zlocation-detail=none >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_LTO=true >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_PANIC=abort >> $GITHUB_ENV
echo BUILD_FLAGS="-Zbuild-std=std,panic_abort --no-default-features -Zbuild-std-features=" >> $GITHUB_ENV
# Build the `wasmtime` executable. Note that we include some non-default
# features so the release artifacts can be maximally feature-ful.
- run: $CENTOS cargo build --release $BUILD_FLAGS --target ${{ matrix.target }}
if: matrix.min
- run: $CENTOS cargo build --release --features all-arch,component-model --target ${{ matrix.target }}
if: '!matrix.min'

# Build `libwasmtime.so`
- run: $CENTOS cargo build --release -p wasmtime-c-api $BUILD_FLAGS --target ${{ matrix.target }}
- run: $CENTOS ./ci/build-release-artifacts.sh "${{ matrix.target }}" ${{ matrix.min }}

# Assemble release artifacts appropriate for this platform, then upload them
# unconditionally to this workflow's files so we have a copy of them.
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}" "${{ matrix.min }}"

- uses: actions/upload-artifact@v3
with:
name: bins-${{ matrix.build }}
Expand Down
32 changes: 32 additions & 0 deletions ci/build-release-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# A small script used for assembling release tarballs for both the `wasmtime`
# binary and the C API. This is executed with two arguments, mostly coming from
# the CI matrix.
#
# * The first argument is the name of the platform, used to name the release
# * The second argument is the "target", if present, currently only for
# cross-compiles
#
# This expects the build to already be done and will assemble release artifacts
# in `dist/`

set -ex

target=$1
min=$2

if [ "$min" == "true" ]; then
export CARGO_PROFILE_RELEASE_STRIP=debuginfo
export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
export RUSTFLAGS=-Zlocation-detail=none
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO=true
export CARGO_PROFILE_RELEASE_PANIC=abort
flags="-Zbuild-std=std,panic_abort --no-default-features -Zbuild-std-features="
else
bin_flags="--features all-arch,component-model"
fi

cargo build --release $flags --target $target -p wasmtime $bin_flags
cargo build --release $flags --target $target -p wasmtime-c-api
40 changes: 27 additions & 13 deletions ci/build-tarballs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set -ex

platform=$1
target=$2
is_min=$3

rm -rf tmp
mkdir tmp
Expand All @@ -37,31 +38,44 @@ cp LICENSE README.md tmp/$bin_pkgname
cp -r crates/c-api/include tmp/$api_pkgname
cp crates/c-api/wasm-c-api/include/wasm.h tmp/$api_pkgname/include

if [ "$is_min" = "true" ]; then
min=-min
fi

fmt=tar
if [ "$platform" = "x86_64-windows" ]; then
cp target/release/wasmtime.exe tmp/$bin_pkgname
cp target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
cp target/release/{wasmtime.dll,wasmtime.lib,wasmtime.dll.lib} tmp/$api_pkgname/lib
cp target/$target/release/wasmtime.dll tmp/$api_pkgname/lib/wasmtime$min.dll
cp target/$target/release/wasmtime.lib tmp/$api_pkgname/lib/wasmtime$min.lib
cp target/$target/release/wasmtime.dll.lib tmp/$api_pkgname/lib/wasmtime$min.dll.lib
fmt=zip

# Generate a `*.msi` installer for Windows as well
export WT_VERSION=`cat Cargo.toml | sed -n 's/^version = "\([^"]*\)".*/\1/p'`
"$WIX/bin/candle" -arch x64 -out target/wasmtime.wixobj ci/wasmtime.wxs
"$WIX/bin/light" -out dist/$bin_pkgname.msi target/wasmtime.wixobj -ext WixUtilExtension
rm dist/$bin_pkgname.wixpdb
if [ "$is_min" = "" ]; then
# Generate a `*.msi` installer for Windows as well
export WT_VERSION=`cat Cargo.toml | sed -n 's/^version = "\([^"]*\)".*/\1/p'`
"$WIX/bin/candle" -arch x64 -out target/wasmtime.wixobj ci/wasmtime.wxs
"$WIX/bin/light" -out dist/$bin_pkgname.msi target/wasmtime.wixobj -ext WixUtilExtension
rm dist/$bin_pkgname.wixpdb
fi
elif [ "$platform" = "x86_64-mingw" ]; then
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname
cp target/$target/release/{wasmtime.dll,libwasmtime.a,libwasmtime.dll.a} tmp/$api_pkgname/lib
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
cp target/$target/release/wasmtime.dll tmp/$api_pkgname/lib/wasmtime$min.dll
cp target/$target/release/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp target/$target/release/libwasmtime.dll.a tmp/$api_pkgname/lib/libwasmtime$min.dll.a
fmt=zip
elif [[ $platform == *-macos ]]; then
# Postprocess the macOS dylib a bit to have a more reasonable `LC_ID_DYLIB`
# directive than the default one that comes out of the linker when typically
# doing `cargo build`. For more info see #984
install_name_tool -id "@rpath/libwasmtime.dylib" target/$target/release/libwasmtime.dylib
cp target/$target/release/wasmtime tmp/$bin_pkgname
cp target/$target/release/libwasmtime.{a,dylib} tmp/$api_pkgname/lib
install_name_tool -id "@rpath/libwasmtime$min.dylib" target/$target/release/libwasmtime.dylib
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
cp target/$target/release/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp target/$target/release/libwasmtime.dylib tmp/$api_pkgname/lib/libwasmtime$min.dylib
else
cp target/$target/release/wasmtime tmp/$bin_pkgname
cp target/$target/release/libwasmtime.{a,so} tmp/$api_pkgname/lib
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
cp target/$target/release/libwasmtime.a tmp/$api_pkgname/lib/libwasmtime$min.a
cp target/$target/release/libwasmtime.so tmp/$api_pkgname/lib/libwasmtime$min.so
fi


Expand Down

0 comments on commit b93c3c9

Please sign in to comment.