From e21456d38f8e4bb9897b8e4a5cb9ef3002b30364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 27 Nov 2022 00:38:13 +0000 Subject: [PATCH] ci: use emsdk instead of download emsdk each build. --- .drone.yml | 8 ++++++-- src/KgmWasm/build-wasm | 34 ++++++++++++++++++---------------- src/QmcWasm/build-wasm | 33 ++++++++++++++++++--------------- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/.drone.yml b/.drone.yml index 925f970..7021d95 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,12 +4,16 @@ type: docker name: default steps: + - name: build-wasm + image: emscripten/emsdk:3.0.0 + commands: + - ./scripts/build-wasm.sh + - name: build image: node:16.18-bullseye commands: - apt-get update - - apt-get install -y cmake jq zip - - ./scripts/build-wasm.sh + - apt-get install -y jq zip - npm ci - npm run test - ./scripts/build-and-package.sh legacy diff --git a/src/KgmWasm/build-wasm b/src/KgmWasm/build-wasm index 85f5658..599b97c 100755 --- a/src/KgmWasm/build-wasm +++ b/src/KgmWasm/build-wasm @@ -8,29 +8,31 @@ CURR_DIR="${PWD}" BUILD_TYPE="$1" if [ -z "$BUILD_TYPE" ]; then - BUILD_TYPE=Release + BUILD_TYPE=Release +fi + +# CI: already had emsdk installed. +if ! command -v emcc; then + if [ ! -d ../../build/emsdk ]; then + git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk + fi + + pushd ../../build/emsdk + ./emsdk install 3.0.0 + ./emsdk activate 3.0.0 + source ./emsdk_env.sh + popd # ../../build/emsdk fi mkdir -p build/wasm -if [ ! -d ../../build/emsdk ]; then - git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk -fi - -pushd ../../build/emsdk -#git pull -./emsdk install 3.0.0 -./emsdk activate 3.0.0 -source ./emsdk_env.sh -popd # ../../build/emsdk - pushd build/wasm emcmake cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" ../.. make -j TARGET_FILES=" - KgmLegacy.js - KgmWasm.js - KgmWasm.wasm - KgmWasmBundle.js + KgmLegacy.js + KgmWasm.js + KgmWasm.wasm + KgmWasmBundle.js " cp $TARGET_FILES "${CURR_DIR}/" diff --git a/src/QmcWasm/build-wasm b/src/QmcWasm/build-wasm index c906fae..4cd1640 100755 --- a/src/QmcWasm/build-wasm +++ b/src/QmcWasm/build-wasm @@ -8,28 +8,31 @@ CURR_DIR="${PWD}" BUILD_TYPE="$1" if [ -z "$BUILD_TYPE" ]; then - BUILD_TYPE=Release + BUILD_TYPE=Release +fi + +# CI: already had emsdk installed. +if ! command -v emcc; then + if [ ! -d ../../build/emsdk ]; then + git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk + fi + + pushd ../../build/emsdk + ./emsdk install 3.0.0 + ./emsdk activate 3.0.0 + source ./emsdk_env.sh + popd # ../../build/emsdk fi mkdir -p build/wasm -if [ ! -d ../../build/emsdk ]; then - git clone https://github.com/emscripten-core/emsdk.git ../../build/emsdk -fi - -pushd ../../build/emsdk -./emsdk install 3.0.0 -./emsdk activate 3.0.0 -source ./emsdk_env.sh -popd # ../../build/emsdk - pushd build/wasm emcmake cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" ../.. make -j TARGET_FILES=" - QmcLegacy.js - QmcWasm.js - QmcWasm.wasm - QmcWasmBundle.js + QmcLegacy.js + QmcWasm.js + QmcWasm.wasm + QmcWasmBundle.js " cp $TARGET_FILES "${CURR_DIR}/"