From 8503368da6b4371e433cd78ed8d0de7817b9d798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Fern=C3=A1ndez=20L=C3=B3pez?= Date: Wed, 15 Feb 2023 12:49:03 +0100 Subject: [PATCH] feature: Add slim and batteries-included Ruby version flavours --- .github/workflows/build-ruby.yaml | 11 ++++---- .github/workflows/release-ruby.yaml | 11 ++++---- ruby/v3_2_0-slim/wl-build.sh | 44 +++++++++++++++++++++++++++++ ruby/v3_2_0-slim/wl-env-repo.sh | 12 ++++++++ ruby/v3_2_0-slim/wl-tag.sh | 1 + ruby/v3_2_0/wl-build.sh | 13 ++++++--- ruby/v3_2_0/wl-env-repo.sh | 1 - 7 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 ruby/v3_2_0-slim/wl-build.sh create mode 100644 ruby/v3_2_0-slim/wl-env-repo.sh create mode 100644 ruby/v3_2_0-slim/wl-tag.sh diff --git a/.github/workflows/build-ruby.yaml b/.github/workflows/build-ruby.yaml index 2b30dea..6998014 100644 --- a/.github/workflows/build-ruby.yaml +++ b/.github/workflows/build-ruby.yaml @@ -12,6 +12,7 @@ jobs: strategy: fail-fast: false matrix: + flavor: ["", "-slim"] include: - version: 3.2.0 target_version: 3_2_0 @@ -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 diff --git a/.github/workflows/release-ruby.yaml b/.github/workflows/release-ruby.yaml index 81fcb3e..020fd97 100644 --- a/.github/workflows/release-ruby.yaml +++ b/.github/workflows/release-ruby.yaml @@ -13,6 +13,7 @@ jobs: release-ruby: strategy: matrix: + flavor: ["", "-slim"] include: - version: 3.2.0 target_version: 3_2_0 @@ -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. # @@ -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. # @@ -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. # @@ -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 @@ -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 diff --git a/ruby/v3_2_0-slim/wl-build.sh b/ruby/v3_2_0-slim/wl-build.sh new file mode 100644 index 0000000..989797e --- /dev/null +++ b/ruby/v3_2_0-slim/wl-build.sh @@ -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}" diff --git a/ruby/v3_2_0-slim/wl-env-repo.sh b/ruby/v3_2_0-slim/wl-env-repo.sh new file mode 100644 index 0000000..f9d0b0f --- /dev/null +++ b/ruby/v3_2_0-slim/wl-env-repo.sh @@ -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 diff --git a/ruby/v3_2_0-slim/wl-tag.sh b/ruby/v3_2_0-slim/wl-tag.sh new file mode 100644 index 0000000..10e3b4a --- /dev/null +++ b/ruby/v3_2_0-slim/wl-tag.sh @@ -0,0 +1 @@ +export WLR_TAG="ruby/3.2.0" diff --git a/ruby/v3_2_0/wl-build.sh b/ruby/v3_2_0/wl-build.sh index c5492fe..7b2f332 100644 --- a/ruby/v3_2_0/wl-build.sh +++ b/ruby/v3_2_0/wl-build.sh @@ -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... " @@ -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 \ @@ -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}" diff --git a/ruby/v3_2_0/wl-env-repo.sh b/ruby/v3_2_0/wl-env-repo.sh index 96966fa..f9d0b0f 100644 --- a/ruby/v3_2_0/wl-env-repo.sh +++ b/ruby/v3_2_0/wl-env-repo.sh @@ -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 -