From f278c2cbedd83054cc3b1ba9024dae2e33dfd68a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:50:08 -0600 Subject: [PATCH 01/14] Delete travis and appveyor --- .travis.yml | 35 ----------------------------------- appveyor.yml | 25 ++----------------------- 2 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1831c829..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: node_js -sudo: false - -notifications: - email: - on_success: never - on_failure: change - -node_js: - - "8" - - "10" - - "12.14.1" - -before_install: - - export CXX="g++-4.9" CC="gcc-4.9" - -script: - - npm run standard - - npm run test:node - - npm run test:native - -git: - depth: 10 - -branches: - only: - - master - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - gcc-4.9 - - g++-4.9 diff --git a/appveyor.yml b/appveyor.yml index aa43e41e..795da41c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,27 +1,6 @@ -image: Visual Studio 2015 - -environment: - matrix: - - nodejs_version: "8" - - nodejs_version: "12.14.1" - -platform: - - x86 - - x64 - -install: - - ps: Install-Product node $env:nodejs_version - - git submodule update --init - - node --version - - npm --version - - npm install - -test_script: - - npm run standard - - npm run test:node - +# empty appveyor build: off branches: only: - - master + - non-existing From 35147b237692f2cdc0d67d12f7f1c637afaa9b03 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:31:43 -0600 Subject: [PATCH 02/14] Add GithubActions --- .github/workflows/ci.yml | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..5a3e43ae --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: ci +on: + - pull_request + - push + +jobs: + Test: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + node_version: + - 10 + - 12 + - 14 + name: Node ${{ matrix.node_version }} on ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Setup node + uses: actions/setup-node@v2-beta + with: + node-version: ${{ matrix.node_version }} + node-arch: ${{ matrix.node_arch }} + + - name: Install dependencies + run: npm install + + - name: Lint + run: npm run standard + + - name: Run tests + run: | + npm run test:node + npm run test:native + + Skip: + if: contains(github.event.head_commit.message, '[skip ci]') + runs-on: ubuntu-latest + steps: + - name: Skip CI 🚫 + run: echo skip ci From 4cf26718f30b877a47bc8a827bf9707263906718 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:37:55 -0600 Subject: [PATCH 03/14] Add fail-fast false to allow all jobs to run --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a3e43ae..f0cf99e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: - ubuntu-latest From cfcb76ef6ad904822c7bc83db017313a0598272f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:42:22 -0600 Subject: [PATCH 04/14] Add missing node in test:native --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b514e5c6..c2d237bc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build:node": "node-gyp rebuild", "build:browser": "script/build-browser-version.sh", "build": "npm run build:node && npm run build:browser", - "test:native": "script/test-native.js", + "test:native": "node ./script/test-native.js", "test:node": "mocha test/js/*.js", "test:browser": "SUPERSTRING_USE_BROWSER_VERSION=1 mocha test/js/*.js", "test": "npm run test:node && npm run test:browser", From b308a0a5dccef6a65e7919375bd8d8473d76e5b3 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:47:11 -0600 Subject: [PATCH 05/14] Cache node_modules --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0cf99e5..72cd4c51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,12 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + - name: Cache + uses: actions/cache@v2 + with: + path: | + 'node_modules' + key: ${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json') }} - name: Setup node uses: actions/setup-node@v2-beta From f28fe65c1d91ea8f3cdd35e61d17160d2cfabbd7 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 22:59:04 -0600 Subject: [PATCH 06/14] Remove CircleCi --- .circleci/config.yml | 59 -------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f0a68d8b..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,59 +0,0 @@ -version: 2 - -jobs: - build: - environment: - XCODE_SCHEME: test - XCODE_WORKSPACE: test - XCODE_PROJECT: test - NODE_VERSION: '10.2.1' - macos: - xcode: 8.3.3 - steps: - - checkout - - run: - name: Update submodules - command: git submodule update --init - - restore_cache: - key: node-{{ .Environment.NODE_VERSION }} - - restore_cache: - key: emsdk-{{ checksum "script/install-emscripten.sh" }} - - run: - name: Install Node.js with nvm - command: | - export NVM_DIR=${HOME}/.nvm - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash - [ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh" - nvm install ${NODE_VERSION} - nvm alias default ${NODE_VERSION} - echo "[ -s \"${NVM_DIR}/nvm.sh\" ] && . \"${NVM_DIR}/nvm.sh\"" >> $BASH_ENV - - run: - name: Install node dependencies - command: npm install - - run: - name: Build with emscripten - command: script/install-emscripten.sh - - save_cache: - key: node-{{ .Environment.NODE_VERSION }} - paths: - - .nvm - - save_cache: - key: emsdk-{{ checksum "script/install-emscripten.sh" }} - paths: - - .emscripten_cache - - emsdk-portable - - run: - name: Build emscripten - command: npm run build:browser - - run: - name: Lint JavaScript - command: npm run standard - - run: - name: Test Browser - command: npm run test:browser - - run: - name: Test Node.js - command: npm run test:node - - run: - name: Test native - command: npm run test:native From cd8b398639afc6e822d970db65ffd813fc32d39e Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 4 Dec 2020 23:02:05 -0600 Subject: [PATCH 07/14] Add wasm version to github actions --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72cd4c51..ed8eb8c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,6 +48,16 @@ jobs: npm run test:node npm run test:native + - name: Install emscripten + shell: bash + run: script/install-emscripten.sh + + - name: Build WASM version + run: npm run build:browser + + - name: Test WASM version + run: npm run test:browser + Skip: if: contains(github.event.head_commit.message, '[skip ci]') runs-on: ubuntu-latest From 0d6d935ce33b472ced5545435fd17956b162fcef Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:47:16 -0600 Subject: [PATCH 08/14] Compile pcre as a library --- script/build-browser-version.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/script/build-browser-version.sh b/script/build-browser-version.sh index bb370e11..023bb4fc 100755 --- a/script/build-browser-version.sh +++ b/script/build-browser-version.sh @@ -1,16 +1,16 @@ #!/usr/bin/env bash -source emsdk-portable/emsdk_env.sh - mkdir -p build +## Compile pcre + emcc \ - -o build/pcre.o \ -O3 \ -I vendor/pcre/10.23/src \ -I vendor/pcre/include \ -D HAVE_CONFIG_H \ -D PCRE2_CODE_UNIT_WIDTH=16 \ + -c \ vendor/pcre/pcre2_chartables.c \ vendor/pcre/10.23/src/pcre2_auto_possess.c \ vendor/pcre/10.23/src/pcre2_compile.c \ @@ -36,6 +36,14 @@ emcc \ vendor/pcre/10.23/src/pcre2_valid_utf.c \ vendor/pcre/10.23/src/pcre2_xclass.c +mv ./*.o build/ + +emar \ + rcs build/pcre.a \ + build/*.o + +### Compile superstring + em++ \ --bind \ -o browser.js \ @@ -44,13 +52,13 @@ em++ \ -I src/core \ -I vendor/libcxx \ -I vendor/pcre/include \ + -D HAVE_CONFIG_H \ -D PCRE2_CODE_UNIT_WIDTH=16 \ - -xc++ \ + -s TOTAL_MEMORY=134217728 \ --pre-js src/bindings/em/prologue.js \ --post-js src/bindings/em/epilogue.js \ src/core/*.cc \ src/bindings/em/*.cc \ - build/pcre.o \ - -s TOTAL_MEMORY=134217728 \ + build/pcre.a \ --memory-init-file 0 \ "$@" From bad6c4b8c99040adcd53186d01b045dea87d01ef Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:48:18 -0600 Subject: [PATCH 09/14] Fix the browser scripts in package.json --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c2d237bc..5b188d79 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "browser": "./browser", "scripts": { "build:node": "node-gyp rebuild", - "build:browser": "script/build-browser-version.sh", + "build:browser": "bash -c ./script/build-browser-version.sh", "build": "npm run build:node && npm run build:browser", "test:native": "node ./script/test-native.js", "test:node": "mocha test/js/*.js", - "test:browser": "SUPERSTRING_USE_BROWSER_VERSION=1 mocha test/js/*.js", + "test:browser": "cross-env SUPERSTRING_USE_BROWSER_VERSION=1 mocha test/js/*.js", "test": "npm run test:node && npm run test:browser", "benchmark": "node benchmark/marker-index.benchmark.js", "prepublishOnly": "npm run build:browser", @@ -35,6 +35,7 @@ }, "devDependencies": { "chai": "^2.0.0", + "cross-env": "^7.0.3", "mocha": "^2.3.4", "random-seed": "^0.2.0", "standard": "^4.5.4", From ebdf886f0ba65e3bcf79d882186dc08872a4d69f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:49:12 -0600 Subject: [PATCH 10/14] Install emsdk 2.0.9 --- script/install-emscripten.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/script/install-emscripten.sh b/script/install-emscripten.sh index 952cbcd4..6b9c6cb1 100755 --- a/script/install-emscripten.sh +++ b/script/install-emscripten.sh @@ -2,8 +2,8 @@ set -e -EMSCRIPTEN_DOWNLOAD_URL='https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz' -EMSDK_PATH="./emsdk-portable/emsdk" +EMSCRIPTEN_DOWNLOAD_URL='https://codeload.github.com/emscripten-core/emsdk/tar.gz/2.0.9' +EMSDK_PATH="./emsdk-2.0.9/emsdk" if [ ! -f $EMSDK_PATH ]; then echo 'Downloading emscripten SDK installer...' @@ -12,11 +12,6 @@ fi echo 'Installing emscripten SDK...' -# Workaround https://github.com/juj/emsdk/pull/74 -sed -i{} "s_/kripken/emscripten/'_/kripken/emscripten'_" $EMSDK_PATH -sed -i{} "s_/WebAssembly/binaryen/'_/WebAssembly/binaryen'_" $EMSDK_PATH - $EMSDK_PATH update -$EMSDK_PATH list -$EMSDK_PATH install sdk-1.37.9-64bit -$EMSDK_PATH activate sdk-1.37.9-64bit +$EMSDK_PATH install 2.0.9 +$EMSDK_PATH activate 2.0.9 --permanent From 718fa18cfe5eb5ef1150e24a8a28dc8d2175839d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:50:24 -0600 Subject: [PATCH 11/14] Update gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 51f142db..567331c6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,9 @@ build .clang_complete /browser.js -emsdk-portable +emsdk-* package-lock.json + +*.wasm +*.o +*.a From 4d5a6fcca8ce25351b896e221c34f375595de417 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:52:47 -0600 Subject: [PATCH 12/14] Fix implicit instantiation of undefined template --- src/bindings/em/patch.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/em/patch.cc b/src/bindings/em/patch.cc index f4626dcc..ebf8b6d6 100644 --- a/src/bindings/em/patch.cc +++ b/src/bindings/em/patch.cc @@ -83,7 +83,7 @@ void change_set_noop(Patch::Change &change, T const &) {} EMSCRIPTEN_BINDINGS(Patch) { emscripten::class_("Patch") .constructor<>() - .constructor(WRAP_STATIC(&constructor), emscripten::allow_raw_pointers()) + .constructor(WRAP_STATIC(&constructor), emscripten::allow_raw_pointers()) .function("splice", splice) .function("splice", splice_with_text) .function("spliceOld", WRAP(&Patch::splice_old)) From b7c0db09d9124eb93da0af28ed019c3f22a53fad Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 05:53:01 -0600 Subject: [PATCH 13/14] Include wire.h --- src/bindings/em/patch.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings/em/patch.cc b/src/bindings/em/patch.cc index ebf8b6d6..059961f1 100644 --- a/src/bindings/em/patch.cc +++ b/src/bindings/em/patch.cc @@ -4,6 +4,7 @@ #include "patch.h" #include #include +#include using std::runtime_error; using std::string; From 201cb8c638bf64feb67fb386f826f6ac016dcf78 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Dec 2020 06:15:09 -0600 Subject: [PATCH 14/14] Activate emsk before building --- script/build-browser-version.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/build-browser-version.sh b/script/build-browser-version.sh index 023bb4fc..73fdf3c3 100755 --- a/script/build-browser-version.sh +++ b/script/build-browser-version.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +# Activate emscripten +EMSDK_PATH="./emsdk-2.0.9/emsdk" +$EMSDK_PATH activate 2.0.9 + +# Build + mkdir -p build ## Compile pcre