Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix native addon for Node 13 and older versions of glibc #720

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ jobs:

prebuild-linux-x64:
docker:
- image: node:10
- image: node:8
working_directory: ~/dd-trace-js
resource_class: small
environment:
Expand All @@ -510,7 +510,7 @@ jobs:

prebuild-linux-x32:
docker:
- image: node:10
- image: node:8
working_directory: ~/dd-trace-js
resource_class: small
environment:
Expand Down Expand Up @@ -611,7 +611,7 @@ jobs:

alpine-prebuilt:
docker:
- image: node:10-alpine
- image: node:alpine
working_directory: ~/dd-trace-js
resource_class: small
steps:
Expand All @@ -629,6 +629,23 @@ jobs:
name: Unit tests
command: yarn test:core

slim-prebuilt:
docker:
- image: node:slim
working_directory: ~/dd-trace-js
resource_class: small
steps:
- checkout
- *yarn-versions
- *restore-yarn-cache
- *yarn-install
- *save-yarn-cache
- restore_cache:
key: prebuild-linux-x64-{{ .Environment.CIRCLE_WORKFLOW_ID }}
- run:
name: Unit tests
command: yarn test:core

browser:
docker:
- image: circleci/node:10-browsers
Expand Down Expand Up @@ -751,6 +768,9 @@ workflows:
- alpine-prebuilt:
requires:
- prebuild-linux-x64
- slim-prebuilt:
requires:
- prebuild-linux-x64
nightly:
triggers:
- schedule:
Expand Down
2 changes: 0 additions & 2 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ dev,karma-mocha,MIT,Copyright 2011-2013 Google, Inc.
dev,karma-webpack,MIT,Copyright JS Foundation and other contributors
dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foundation
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
dev,node-abi,MIT,Copyright 2016 Lukas Geiger
dev,nyc,ISC,Copyright 2015 Contributors
dev,prebuildify,MIT,Copyright 2017 Mathias Buus
dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz
dev,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
dev,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
"karma-webpack": "^4.0.2",
"mocha": "^5.2.0",
"nock": "^11.3.3",
"node-abi": "^2.8.0",
"nyc": "^14.1.1",
"prebuildify": "^2.11.0",
"proxyquire": "^1.8.0",
"retry": "^0.10.1",
"sinon": "^4.2.1",
Expand Down
73 changes: 59 additions & 14 deletions scripts/prebuild.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,61 @@
'use strict'

const prebuildify = require('prebuildify')
const abi = require('node-abi')
const path = require('path')
const os = require('os')
const tar = require('tar')
const semver = require('semver')
const fs = require('fs')
const execSync = require('child_process').execSync

const name = `${os.platform()}-${process.env.ARCH || os.arch()}`
const targets = abi.allTargets
.filter(target => target.runtime === 'node')
.filter(target => semver.satisfies(target.target, '>=8.0.0'))
const platform = os.platform()
const arch = process.env.ARCH || os.arch()
const name = `${platform}-${arch}`

const cb = err => {
if (err) throw err
// https://nodejs.org/en/download/releases/
const targets = [
{ version: '8.0.0', abi: '57' },
{ version: '9.0.0', abi: '59' },
{ version: '10.0.0', abi: '64' },
{ version: '11.0.0', abi: '67' },
{ version: '12.0.0', abi: '72' },
{ version: '13.0.0', abi: '79' }
]

prebuildify()
pack()

function retry (cmd) {
try {
execSync(cmd, { stdio: [0, 1, 2] })
} catch (e) {
retry(cmd)
}
}

function prebuildify () {
const cache = path.join(os.tmpdir(), 'prebuilds')

mkdirSafe(cache)
mkdirSafe('prebuilds')
mkdirSafe(`prebuilds/${platform}-${arch}`)

targets.forEach(target => {
const cmd = [
'node-gyp rebuild',
`--target=${target.version}`,
`--target_arch=${arch}`,
`--devdir=${cache}`,
'--release',
'--build_v8_with_gn=false',
'--enable_lto=false'
].join(' ')

retry(cmd)

fs.copyFileSync('build/Release/metrics.node', `prebuilds/${platform}-${arch}/node-${target.abi}.node`)
})
}

function pack () {
fs.copyFileSync(
path.join(__dirname, '..', 'packages', 'dd-trace', 'src', 'native', 'tdigest', 'NOTICES'),
path.join(__dirname, '..', 'prebuilds', 'NOTICES')
Expand All @@ -32,10 +72,15 @@ const cb = err => {
portable: true,
file: `addons-${name}.tgz`,
cwd: path.join(__dirname, '..')
}, ['prebuilds'])
}, [
`prebuilds/${platform}-${arch}`,
'prebuilds/NOTICES',
'prebuilds/LICENSE-2.0.txt'
])
}

prebuildify({
targets,
strip: false
}, cb)
function mkdirSafe (filename) {
if (!fs.existsSync(filename)) {
fs.mkdirSync(filename)
}
}