From f912b4c2b92c39380ecfaa8b7cc28578038ac537 Mon Sep 17 00:00:00 2001 From: dm4 Date: Mon, 13 Sep 2021 15:05:51 +0800 Subject: [PATCH] [Script] Use install script from WasmEdge --- .github/workflows/external-test.yml | 53 ++++++++++++++--------------- .github/workflows/main.yml | 11 ++++-- binding.gyp | 4 +-- package.json | 5 ++- scripts/preinstall.sh | 10 ++++-- scripts/release.sh | 2 +- test/test.sh | 8 +++-- 7 files changed, 52 insertions(+), 41 deletions(-) diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml index 9954b7b..b22ee7e 100644 --- a/.github/workflows/external-test.yml +++ b/.github/workflows/external-test.yml @@ -21,26 +21,22 @@ jobs: node-version: [10.x, 12.x, 14.x] include: - node-version: '14.x' - ssvm-options: '--enable-aot' + rustwasmc-options: '--enable-aot' steps: - # MAGIC: Checkout wasm-learning at $GITHUB_WORKSPACE so that node - # module search will find 'ssvm' from inside the testdirs. + - uses: actions/checkout@v2 + - name: Checkout wasm-learning uses: actions/checkout@v2 with: repository: second-state/wasm-learning + path: wasm-learning - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: Checkout wasmedge-core - uses: actions/checkout@v2 - with: - path: wasmedge-core - - name: Set Rust to required version uses: actions-rs/toolchain@v1 with: @@ -49,44 +45,45 @@ jobs: - name: Install dependencies run: | + apt update && apt install -y sudo npm install --unsafe-perm -g rustwasmc + ln -s $(which node) /usr/local/bin/node + ln -s $(which npm) /usr/local/bin/npm - name: Build and install wasmedge-core - uses: './wasmedge-core/.github/actions/build-from-source' - with: - path: './wasmedge-core' + uses: './.github/actions/build-from-source' - - name: Test functions ${{ matrix.ssvm-options }} + - name: Test functions ${{ matrix.rustwasmc-options }} run: | - rustwasmc build ${{ matrix.ssvm-options }} - sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js + rustwasmc build ${{ matrix.rustwasmc-options }} + cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd .. node node/app.js rustwasmc clean - working-directory: nodejs/functions + working-directory: wasm-learning/nodejs/functions - - name: Test JSON IO ${{ matrix.ssvm-options }} + - name: Test JSON IO ${{ matrix.rustwasmc-options }} run: | - rustwasmc build ${{ matrix.ssvm-options }} - sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js + rustwasmc build ${{ matrix.rustwasmc-options }} + cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd .. node node/app.js rustwasmc clean - working-directory: nodejs/json_io + working-directory: wasm-learning/nodejs/json_io - - name: Test WASI ${{ matrix.ssvm-options }} + - name: Test WASI ${{ matrix.rustwasmc-options }} run: | - rustwasmc build ${{ matrix.ssvm-options }} - sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js + rustwasmc build ${{ matrix.rustwasmc-options }} + cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd .. node node/app.js rustwasmc clean - working-directory: nodejs/wasi + working-directory: wasm-learning/nodejs/wasi - - name: Test KMeans ${{ matrix.ssvm-options }} - if: ${{ contains(matrix.ssvm-options, 'aot') }} + - name: Test KMeans ${{ matrix.rustwasmc-options }} + if: ${{ contains(matrix.rustwasmc-options, 'aot') }} run: | - rustwasmc build ${{ matrix.ssvm-options }} - sed -i "s/require('ssvm')/require('wasmedge-core')/" pkg/*.js + rustwasmc build ${{ matrix.rustwasmc-options }} + cd pkg && sudo npm i ${GITHUB_WORKSPACE} && cd .. cd node node app.js cd - rustwasmc clean - working-directory: nodejs/kmeans + working-directory: wasm-learning/nodejs/kmeans diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f2fffe..39a94a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,12 +42,19 @@ jobs: toolchain: 1.50.0 override: true - - name: Build SSVM-napi with ${{ matrix.cc }} + - name: Install dependencies + run: | + apt update && apt install -y sudo + npm install --unsafe-perm -g rustwasmc + ln -s $(which node) /usr/local/bin/node + ln -s $(which npm) /usr/local/bin/npm + + - name: Build wasmedge-core with ${{ matrix.cc }} uses: './.github/actions/build-from-source' with: cc: ${{ matrix.cc }} cxx: ${{ matrix.cxx }} - - name: Test SSVM-napi built with ${{ matrix.cc }} + - name: Test wasmedge-core built with ${{ matrix.cc }} run: | JOBS=max npm test diff --git a/binding.gyp b/binding.gyp index 7d48b59..0130484 100644 --- a/binding.gyp +++ b/binding.gyp @@ -7,7 +7,7 @@ "cflags_cc!": [ "-fno-exceptions", "-fno-rtti" ], "link_settings": { "libraries": [ - "/usr/local/lib/libwasmedge_c.so", + "$(HOME)/.wasmedge/lib/libwasmedge_c.so", ], }, "sources": [ @@ -20,7 +20,7 @@ "include_dirs": [ "