forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: build test add-ons like third-party add-ons
Until now we built add-ons by pointing node-gyp at the src/ directory. We've had at least one DOA release where add-ons were broken because of a header dependency issue that wasn't caught because we build our test add-ons in a non-standard way. This commit does the following: * Use tools/install.py to install the headers to test/addons/include. * Add a script to build everything in test/addons. * Remove the pile-up of hacks from the Makefile. Refs: nodejs#11628
- Loading branch information
1 parent
3be1db8
commit 678a3dc
Showing
6 changed files
with
100 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const { spawnSync } = require('child_process'); | ||
const { resolve } = require('path'); | ||
|
||
const kTopLevelDirectory = resolve(__dirname, '..'); | ||
const kAddonsDirectory = resolve(kTopLevelDirectory, 'test/addons'); | ||
|
||
const kPython = process.env.PYTHON || 'python'; | ||
const kNodeGyp = | ||
resolve(kTopLevelDirectory, 'deps/npm/node_modules/node-gyp/bin/node-gyp'); | ||
|
||
process.chdir(kTopLevelDirectory); | ||
|
||
// Copy headers to test/addons/include. install.py preserves timestamps. | ||
{ | ||
const args = [ 'tools/install.py', 'install', kAddonsDirectory, '/' ]; | ||
const env = Object.assign({}, process.env); | ||
env.HEADERS_ONLY = 'yes, please'; // Ask nicely. | ||
env.LOGLEVEL = 'WARNING'; | ||
|
||
const options = { env, stdio: 'inherit' }; | ||
spawnSync(kPython, args, options); | ||
} | ||
|
||
// Scrape embedded add-ons from doc/api/addons.md. | ||
require('./doc/addon-verify.js'); | ||
|
||
// Regenerate build files and rebuild if necessary. | ||
for (const basedir of fs.readdirSync(kAddonsDirectory)) { | ||
const path = resolve(kAddonsDirectory, basedir); | ||
if (!fs.statSync(path).isDirectory()) continue; | ||
|
||
const gypfile = resolve(path, 'binding.gyp'); | ||
if (!fs.existsSync(gypfile)) continue; | ||
|
||
const args = [ kNodeGyp, | ||
'--directory=' + path, | ||
'--loglevel=silent', | ||
'--nodedir=' + kAddonsDirectory, | ||
'--python=' + kPython ]; | ||
const env = Object.assign({}, process.env); | ||
env.MAKEFLAGS = '-j1'; | ||
|
||
const options = { env, stdio: 'inherit' }; | ||
{ | ||
const proc = spawnSync(process.execPath, args.concat('configure'), options); | ||
if (proc.status !== 0) process.exit(1); | ||
} | ||
{ | ||
const proc = spawnSync(process.execPath, args.concat('build'), options); | ||
if (proc.status !== 0) process.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters