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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ed8eb8c3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: ci +on: + - pull_request + - push + +jobs: + Test: + if: "!contains(github.event.head_commit.message, '[skip ci]')" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + 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: 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 + 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 + + - 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 + steps: + - name: Skip CI 🚫 + run: echo skip ci 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 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 diff --git a/package.json b/package.json index b514e5c6..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": "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: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", diff --git a/script/build-browser-version.sh b/script/build-browser-version.sh index bb370e11..73fdf3c3 100755 --- a/script/build-browser-version.sh +++ b/script/build-browser-version.sh @@ -1,16 +1,22 @@ #!/usr/bin/env bash -source emsdk-portable/emsdk_env.sh +# Activate emscripten +EMSDK_PATH="./emsdk-2.0.9/emsdk" +$EMSDK_PATH activate 2.0.9 + +# Build 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 +42,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 +58,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 \ "$@" 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 diff --git a/src/bindings/em/patch.cc b/src/bindings/em/patch.cc index f4626dcc..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; @@ -83,7 +84,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))