Skip to content

Commit

Permalink
Merge pull request #62 from ereslibre/ruby-flavours
Browse files Browse the repository at this point in the history
feature: Add slim and batteries-included Ruby version flavours
  • Loading branch information
ereslibre authored Feb 15, 2023
2 parents 39691b7 + 8503368 commit 1349da9
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 15 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build-ruby.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
flavor: ["", "-slim"]
include:
- version: 3.2.0
target_version: 3_2_0
Expand All @@ -20,14 +21,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Ruby
run: make ruby/v${{ matrix.target_version }}
run: make ruby/v${{ matrix.target_version }}${{ matrix.flavor }}
- name: Rename artifacts
shell: bash
run: |
sudo mv build-output/ruby/v${{ matrix.target_version }}/bin/ruby{,-${{ matrix.version }}}.wasm
- name: Upload ruby-${{ matrix.version }}.wasm artifact
sudo mv build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby{,-${{ matrix.version }}${{ matrix.flavor }}}.wasm
- name: Upload ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm artifact
uses: actions/upload-artifact@v3
with:
name: ruby-${{ matrix.version }}.wasm
path: build-output/ruby/v${{ matrix.target_version }}/bin/ruby-${{ matrix.version }}.wasm
name: ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm
path: build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby-${{ matrix.version }}${{ matrix.flavor }}.wasm
if-no-files-found: error
11 changes: 6 additions & 5 deletions .github/workflows/release-ruby.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
release-ruby:
strategy:
matrix:
flavor: ["", "-slim"]
include:
- version: 3.2.0
target_version: 3_2_0
Expand All @@ -31,7 +32,7 @@ jobs:
# This if could be moved to the parent `job` section when it's
# supported by GitHub (https://github.com/community/community/discussions/37883)
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
run: make ruby/v${{ matrix.target_version }}
run: make ruby/v${{ matrix.target_version }}${{ matrix.flavor }}
- name: Rename release artifacts
# Only run for the Ruby version specified in the git tag.
#
Expand All @@ -40,7 +41,7 @@ jobs:
if: startsWith(github.event.ref, format('refs/tags/ruby/{0}+', matrix.version))
shell: bash
run: |
sudo mv build-output/ruby/v${{ matrix.target_version }}/bin/ruby{,-${{ matrix.version }}}.wasm
sudo mv build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/ruby{,-${{ matrix.version }}${{ matrix.flavor }}}.wasm
- name: Create release
# Only run for the Ruby version specified in the git tag.
#
Expand All @@ -61,7 +62,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} \
build-output/ruby/v${{ matrix.target_version }}/bin/*.wasm
build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.wasm
- name: Generate release assets digests
# Only run for the Ruby version specified in the git tag.
#
Expand All @@ -71,7 +72,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for asset in build-output/ruby/v${{ matrix.target_version }}/bin/*.wasm; do
for asset in build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.wasm; do
sha256sum "$asset" | sudo tee "$asset.sha256sum" > /dev/null
done
- name: Append release assets digests
Expand All @@ -84,4 +85,4 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} \
build-output/ruby/v${{ matrix.target_version }}/bin/*.sha256sum
build-output/ruby/v${{ matrix.target_version }}${{ matrix.flavor }}/bin/*.sha256sum
44 changes: 44 additions & 0 deletions ruby/v3_2_0-slim/wl-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

if [[ ! -v WASMLABS_ENV ]]
then
echo "Wasmlabs environment is not set"
exit 1
fi

cd "${WASMLABS_SOURCE_PATH}"

export PREFIX=/wlr-rubies

if [[ -z "$WASMLABS_SKIP_CONFIGURE" ]]; then
logStatus "Downloading autotools data... "
ruby tool/downloader.rb -d tool -e gnu config.guess config.sub

logStatus "Generating configure script... "
./autogen.sh

logStatus "Configuring ruby..."
./configure \
--host wasm32-unknown-wasi \
--prefix=$PREFIX \
--with-ext="" \
--with-static-linked-ext \
--disable-install-doc \
LDFLAGS=" \
-Xlinker --stack-first \
-Xlinker -z -Xlinker stack-size=16777216 \
" \
optflags="-O2" \
debugflags="" \
wasmoptflags="-O2"
else
logStatus "Skipping configure..."
fi

logStatus "Building ruby..."
make install

logStatus "Preparing artifacts... "
mv $PREFIX/bin/ruby ${WASMLABS_OUTPUT}/bin/ruby.wasm || exit 1

logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"
12 changes: 12 additions & 0 deletions ruby/v3_2_0-slim/wl-env-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

if [[ $1 == "--unset" ]]
then
unset WASMLABS_REPO
unset WASMLABS_REPO_NAME
return
fi

export WASMLABS_REPO=https://github.com/ruby/ruby.git
export WASMLABS_REPO_NAME=ruby
export WASMLABS_REPO_BRANCH=v3_2_0
1 change: 1 addition & 0 deletions ruby/v3_2_0-slim/wl-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export WLR_TAG="ruby/3.2.0"
13 changes: 9 additions & 4 deletions ruby/v3_2_0/wl-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ fi

cd "${WASMLABS_SOURCE_PATH}"

mkdir -p build
export PREFIX=/wlr-rubies
export XLDFLAGS="/wasi-vfs/lib/libwasi_vfs.a $XLDFLAGS"

if [[ -z "$WASMLABS_SKIP_CONFIGURE" ]]; then
logStatus "Downloading autotools data... "
Expand All @@ -20,8 +21,10 @@ if [[ -z "$WASMLABS_SKIP_CONFIGURE" ]]; then
logStatus "Configuring ruby..."
./configure \
--host wasm32-unknown-wasi \
--with-ext=ripper,monitor \
--prefix=$PREFIX \
--with-ext=bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor \
--with-static-linked-ext \
--disable-install-doc \
LDFLAGS=" \
-Xlinker --stack-first \
-Xlinker -z -Xlinker stack-size=16777216 \
Expand All @@ -34,9 +37,11 @@ else
fi

logStatus "Building ruby..."
make ruby
make install

logStatus "Preparing artifacts... "
mv ruby ${WASMLABS_OUTPUT}/bin/ruby.wasm || exit 1
mv $PREFIX/bin/ruby ruby
rm -rf $PREFIX/bin
wasi-vfs pack ruby --mapdir $PREFIX::$PREFIX -o ${WASMLABS_OUTPUT}/bin/ruby.wasm || exit 1

logStatus "DONE. Artifacts in ${WASMLABS_OUTPUT}"
1 change: 0 additions & 1 deletion ruby/v3_2_0/wl-env-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ fi
export WASMLABS_REPO=https://github.com/ruby/ruby.git
export WASMLABS_REPO_NAME=ruby
export WASMLABS_REPO_BRANCH=v3_2_0

0 comments on commit 1349da9

Please sign in to comment.