Skip to content

Commit

Permalink
Try switching to prebuildify
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed May 13, 2021
1 parent 6c1816d commit 43f11c2
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 106 deletions.
Binary file removed .travis.id_rsa.enc
Binary file not shown.
100 changes: 52 additions & 48 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
language: c++
compiler:
- clang
- gcc
env:
- TRAVIS_NODE_VERSION="10" npm_config_runtime="electron" npm_config_target="3.0.8" npm_config_dist_url=https://atom.io/download/electron
- TRAVIS_NODE_VERSION="10"
- TRAVIS_NODE_VERSION="12"
- TRAVIS_NODE_VERSION="13"
os:
- linux
- osx
matrix:
fast_finish: true
sudo: false

env:
- CXX=g++-4.9
- CXX=clang++

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
before_install:
- echo "$TRAVIS_NODE_VERSION"
- export "PATH=./node_modules/.bin:$PWD/node_modules/.bin:$HOME/.local/bin:$PATH"
- if [ -n "$TRAVIS_TAG" ]; then openssl aes-256-cbc -K $encrypted_5d419efedfca_key -iv $encrypted_5d419efedfca_iv -in .travis.id_rsa.enc -out .travis.id_rsa -d; fi
- if [ -n "$TRAVIS_TAG" ]; then chmod 0600 .travis.id_rsa; fi
# dummy 7z because npm wants to run the prepublish script
- mkdir -p $HOME/.local/bin/ && touch $HOME/.local/bin/7z && chmod +x $HOME/.local/bin/7z
# coveralls
- if [ -z "$TRAVIS_TAG" -a "$TRAVIS_OS_NAME" = "linux" ]; then export DO_COVERAGE=1; fi
- if [ -n "$DO_COVERAGE" ]; then pip install --user cpp-coveralls coveralls-merge; fi
# compilers
- if [ "$CXX" = "g++" -a "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="g++-4.9" CC="gcc-4.9" AR="gcc-ar-4.9" RANLIB="gcc-ranlib-4.9" NM="gcc-nm-4.9" ; fi
- if [ "$CXX" = "clang++" ]; then export npm_config_clang=1 ; fi
# node versions
- rm -rf ~/.nvm
- git clone --branch v0.33.11 https://github.com/creationix/nvm.git ~/.nvm
- source ~/.nvm/nvm.sh
- nvm install "$TRAVIS_NODE_VERSION"
- node --version
# no coverage for tags (they are release builds!)
- if [ -n "$TRAVIS_TAG" ]; then export CFLAGS="$CFLAGS -O3" LDFLAGS="$LDFLAGS"; fi
- if [ -n "$DO_COVERAGE" ]; then export LDFLAGS="$LDFLAGS --coverage" CFLAGS="$CFLAGS --coverage"; fi
- echo "CFLAGS=\"$CFLAGS\" LDFLAGS=\"$LDFLAGS\""
- unset NVM_IOJS_ORG_MIRROR

language: node_js

os:
- linux
- osx

osx_image: xcode10

node_js:
- "12"
- "14"
- "16"

jobs:
include:
- os: linux
arch: arm64
node_js: 12
env: CXX=g++-4.9
exclude:
- os: osx
env: CXX=g++-4.9
- os: linux
env: CXX=clang++

install:
- npm install --build-from-source --verbose
script:
- if [ x"$npm_config_runtime" != x"electron" ]; then node --expose-gc ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec -s 1000 -t 5000; fi
- npm run jshint
- npm install --build-from-source

after_success:
- if [ -n "$DO_COVERAGE" ]; then cpp-coveralls --gcov-options '\-lp' --build-root build --exclude build/liblzma --exclude node_modules --dump coverage/cppfiles.json; fi
- if [ -n "$DO_COVERAGE" ]; then coveralls --stdout < coverage/lcov.info > coverage/jsfiles.json; fi
- if [ -n "$DO_COVERAGE" ]; then coveralls-merge coverage/jsfiles.json coverage/cppfiles.json; fi
# publish for node-pre-gyp
- node-pre-gyp package
- if [ -n "$TRAVIS_TAG" ] && ([ $CXX = "g++" ] || [ $CXX = "g++-4.9" ]); then echo 'put build/stage/lzma-native/* uploads/lzma-native/' |sftp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -b- -i .travis.id_rsa node-pre-gyp@addaleax.net; fi
- npm install coveralls
- nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls

before_deploy:
- ARCHIVE_NAME="${TRAVIS_TAG:-latest}-$TRAVIS_OS_NAME-`uname -m`.tar"
- npm run prebuild --v8_enable_pointer_compression=false --v8_enable_31bit_smis_on_64bit_arch=false
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ARCH=ia32 npm run prebuild --v8_enable_pointer_compression=false --v8_enable_31bit_smis_on_64bit_arch=false; fi
- tar --create --verbose --file="$ARCHIVE_NAME" --directory "$TRAVIS_BUILD_DIR/prebuilds" .

deploy:
provider: releases
draft: false
prerelease: true
file: "$ARCHIVE_NAME"
skip_cleanup: true
on:
tags: true
node: 12
api_key: $PREBUILD_GITHUB_TOKEN
52 changes: 25 additions & 27 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,50 @@
environment:
fast_finish: true
matrix:
- nodejs_version: "13"
- nodejs_version: "14"
- nodejs_version: "12"
- nodejs_version: "10"

platform:
- x86
- x64

# Install scripts. (runs after repo cloning)
install:
- python -V
- set PYTHON=python
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:PLATFORM
- ps: Install-Product node $env:nodejs_version $env:platform
- node -p process.arch
- node -p process.version
- npm install node-gyp@3.6.1
- npm install nan node-pre-gyp readable-stream rimraf
- IF %nodejs_version% LSS 1 npm -g install npm
- IF %nodejs_version% LSS 1 set PATH=%APPDATA%\npm;%PATH%
- npm run prepare
- set GYP_TARGET_ARCH=%PLATFORM:x86=ia32%
- echo %GYP_TARGET_ARCH%
- md build
- npm install --build-from-source --target_arch=%GYP_TARGET_ARCH%
- node_modules\.bin\node-pre-gyp package --target_arch=%GYP_TARGET_ARCH% %NPG_ARGS%
- move build\stage\lzma-native lzma-native
- npm run prepare-win32
- npm install --build-from-source

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

after_test:
- ps: If ($env:nodejs_version -eq "14") { npm run prebuild --v8_enable_pointer_compression=false --v8_enable_31bit_smis_on_64bit_arch=false }

# Don't actually build.
build: off

version: "{build}"

artifacts:
path: lzma-native\*.gz
name: npg-package
- path: prebuilds
name: $(APPVEYOR_REPO_TAG_NAME)-win-$(PLATFORM)
type: zip

deploy:
provider: FTP
protocol: sftp
host: entless.org
username: node-pre-gyp
password:
secure: wvUCOyy2vjKjWyxk4lnoW7s1i2oiK1QhQFlBPKiKefl0cReZ0k/7iD7PBRjrh8OpUbZ05Jgc+pEYHC3sl87tVLB5pDS+jU++dPSXgHb1UmE=
artifact: /npg-package/
folder: uploads
# only build on tags
on:
appveyor_repo_tag: true
- provider: GitHub
artifact: /.*\.zip/
draft: false
prerelease: true
auth_token: $(PREBUILD_GITHUB_TOKEN)
on:
appveyor_repo_tag: true
nodejs_version: "12"
13 changes: 1 addition & 12 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"variables": {
"dlldir%": "<(module_path)"
"dlldir%": "<(module_root_dir)/build/Release"
},
"targets": [
{
Expand Down Expand Up @@ -94,17 +94,6 @@
]
} ],
]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
}
]
}
]
}
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ var assert = require('assert');
var fs = require('fs');
var util = require('util');

// node-pre-gyp magic
var nodePreGyp = require('@mapbox/node-pre-gyp');
var path = require('path');
var binding_path = nodePreGyp.find(path.resolve(path.join(__dirname,'./package.json')));
var native = require(binding_path);
var native = require('node-gyp-build')(__dirname);

Object.assign(exports, native);

Expand Down
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
"lzmajs": "bin/lzmajs"
},
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.1",
"node-addon-api": "^3.1.0",
"readable-stream": "^3.6.0",
"rimraf": "^3.0.2"
"node-gyp-build": "^4.2.1"
},
"keywords": [
"lzma",
Expand All @@ -33,9 +32,12 @@
"url": "https://github.com/addaleax/lzma-native.git"
},
"scripts": {
"install": "node-pre-gyp install --fallback-to-build && rimraf build",
"install": "node-gyp-build",
"prebuild": "prebuildify --napi --tag-armv",
"prepack": "prebuildify-ci download && ([ $(ls prebuilds | wc -l) = '5' ] || (echo 'Some prebuilds are missing'; exit 1))",
"test": "mocha --expose-gc -s 1000 -t 5000",
"prepare": "cd deps && 7z x -y xz-5.2.3-windows.7z bin_i686/liblzma.dll bin_x86-64/liblzma.dll include doc/liblzma.def",
"prepare": "npm run prepare-win32 || true",
"prepare-win32": "cd deps && 7z x -y xz-5.2.3-windows.7z bin_i686/liblzma.dll bin_x86-64/liblzma.dll include doc/liblzma.def",
"jshint": "jshint ."
},
"gypfile": true,
Expand All @@ -44,16 +46,9 @@
},
"devDependencies": {
"bl": "^4.1.0",
"coveralls": "^3.1.0",
"istanbul": "^0.4.2",
"jshint": "^2.12.0",
"mocha": "^8.3.1"
},
"binary": {
"module_name": "lzma_native",
"module_path": "./binding-v{version}-n-api-{platform}-{arch}/",
"host": "https://node-pre-gyp.addaleax.net",
"remote_path": "./lzma-native/",
"package_name": "lzma_native-v{version}-n-api-{platform}-{arch}.tar.gz"
"mocha": "^8.3.1",
"prebuildify": "^3.0.4",
"prebuildify-ci": "^1.0.5"
}
}

0 comments on commit 43f11c2

Please sign in to comment.