From 8e4374282a720c605bb9856dcd564d2fcec09baf Mon Sep 17 00:00:00 2001 From: Abhishek Aggarwal Date: Tue, 31 Aug 2021 15:45:14 +0200 Subject: [PATCH] Circle CI wasm artifacts for non-wormhole builds --- .circleci/config.yml | 41 ++++++++++++++++++++++++++++++-- build-wasm.sh | 56 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 82 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69ae356..9b14ed1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,37 @@ version: 2.1 jobs: - build: + build-with-wormhole: + docker: + - image: 'emscripten/emsdk:2.0.9' + resource_class: medium + + working_directory: ~/checkout + + steps: + - checkout + + - run: + name: Build WASM + command: bash build-wasm.sh WORMHOLE + + - run: + name: Check artifacts + working_directory: build-wasm + command: | + ls -all bergamot* + if ls bergamot*.wasm &>/dev/null && ls bergamot*.js &>/dev/null + then + echo "Artifacts Successfully Generated" + else + echo "Failure: Artifacts Not Present" + exit 1 + fi + + - store_artifacts: + path: "build-wasm" + destination: "wasm-wormhole" + + build-without-wormhole: docker: - image: 'emscripten/emsdk:2.0.9' resource_class: medium @@ -29,4 +60,10 @@ jobs: - store_artifacts: path: "build-wasm" - destination: "build-wasm" + destination: "wasm-without-wormhole" + +workflows: + build: + jobs: + - build-with-wormhole + - build-without-wormhole \ No newline at end of file diff --git a/build-wasm.sh b/build-wasm.sh index d3cd9d1..7da2685 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -1,15 +1,38 @@ #!/usr/bin/env bash - -# Usage: ./build-wasm.sh - set -e set -x +# Usage +Usage="Build translator to wasm (with/without wormhole). + +Usage: $(basename "$0") [WORMHOLE] + + where: + WORMHOLE An optional string argument + - when specified on command line, builds wasm artifacts with wormhole + - when not specified (the default behaviour), builds wasm artifacts without wormhole." + +if [ "$#" -gt 1 ]; then + echo "Illegal number of parameters passed" + echo "$Usage" + exit +fi + +WORMHOLE=false + +if [ "$#" -eq 1 ]; then + if [ "$1" = "WORMHOLE" ]; then + WORMHOLE=true + else + echo "Illegal parameter passed" + echo "$Usage" + exit + fi +fi + # Run script from the context of the script-containing directory cd "$(dirname $0)" -# This file replicates the instructions found in ./README.md under "Build WASM" - # Prerequisite: Download and Install Emscripten using following instructions (unless the EMSDK env var is already set) if [ "$EMSDK" == "" ]; then EMSDK_UPDATE_REQUIRED=0 @@ -36,17 +59,24 @@ if [ "$EMSDK" == "" ]; then fi # Compile -# 1. Create a folder where you want to build all the artifacts (`build-wasm` in this case) and compile -if [ ! -d "build-wasm" ]; then - mkdir build-wasm +# 1. Create a folder where you want to build all the artifacts and compile +BUILD_DIRECTORY="build-wasm" +if [ ! -d ${BUILD_DIRECTORY} ]; then + mkdir ${BUILD_DIRECTORY} +fi +cd ${BUILD_DIRECTORY} + +if [ "$WORMHOLE" = true ]; then + emcmake cmake -DCOMPILE_WASM=on ../ +else + emcmake cmake -DCOMPILE_WASM=on -DWORMHOLE=off ../ fi -cd build-wasm -emcmake cmake -DCOMPILE_WASM=on ../ emmake make -j2 # 2. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts -bash ../wasm/patch-artifacts-enable-wormhole.sh - -# The artifacts (.js and .wasm files) will be available in the build directory ("build-wasm" in this case). +if [ "$WORMHOLE" = true ]; then + bash ../wasm/patch-artifacts-enable-wormhole.sh +fi +# The artifacts (.js and .wasm files) will be available in the build directory exit 0