-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
src: add support for locally installed headers #2964
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a5ac175
feat: add support for locally installed headers
mhdawson d17602b
squash: address windows failure
mhdawson 599932b
squash: address windows ci failures
mhdawson 178fcd5
address review comments
mhdawson 7315afd
Update lib/configure.js
lukekarrys 65292ff
Update lib/configure.js
lukekarrys b4dcacd
Update lib/configure.js
lukekarrys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,123 @@ | ||
| 'use strict' | ||
|
|
||
| const { describe, it } = require('mocha') | ||
| const assert = require('assert') | ||
| const path = require('path') | ||
| const os = require('os') | ||
| const gyp = require('../lib/node-gyp') | ||
| const requireInject = require('require-inject') | ||
| const semver = require('semver') | ||
|
|
||
| const versionSemver = semver.parse(process.version) | ||
|
|
||
| const configure = requireInject('../lib/configure', { | ||
| 'graceful-fs': { | ||
| openSync: () => 0, | ||
| closeSync: () => {}, | ||
| existsSync: () => true, | ||
| readFileSync: () => '#define NODE_MAJOR_VERSION ' + versionSemver.major + '\n' + | ||
| '#define NODE_MINOR_VERSION ' + versionSemver.minor + '\n' + | ||
| '#define NODE_PATCH_VERSION ' + versionSemver.patch + '\n', | ||
| promises: { | ||
| stat: async () => ({}), | ||
| mkdir: async () => {}, | ||
| writeFile: async () => {} | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const configure2 = requireInject('../lib/configure', { | ||
| 'graceful-fs': { | ||
| openSync: () => 0, | ||
| closeSync: () => {}, | ||
| existsSync: () => true, | ||
| readFileSync: () => '#define NODE_MAJOR_VERSION 8\n' + | ||
| '#define NODE_MINOR_VERSION 0\n' + | ||
| '#define NODE_PATCH_VERSION 0\n', | ||
| promises: { | ||
| stat: async () => ({}), | ||
| mkdir: async () => {}, | ||
| writeFile: async () => {} | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const SPAWN_RESULT = cb => ({ on: function () { cb() } }) | ||
|
|
||
| const driveLetter = os.platform() === 'win32' ? `${process.cwd().split(path.sep)[0]}` : '' | ||
| function checkTargetPath (target, value) { | ||
| let targetPath = path.join(path.sep, target, 'include', | ||
| 'node', 'common.gypi') | ||
| if (process.platform === 'win32') { | ||
| targetPath = driveLetter + targetPath | ||
| } | ||
|
|
||
| return targetPath.localeCompare(value) === 0 | ||
| } | ||
|
|
||
| describe('configure-nodedir', function () { | ||
| it('configure nodedir with node-gyp command line', function (done) { | ||
| const prog = gyp() | ||
| prog.parseArgv(['dummy_prog', 'dummy_script', '--nodedir=' + path.sep + 'usr']) | ||
|
|
||
| prog.spawn = function (program, args) { | ||
| for (let i = 0; i < args.length; i++) { | ||
| if (checkTargetPath('usr', args[i])) { | ||
| return SPAWN_RESULT(done) | ||
| } | ||
| }; | ||
| assert.fail() | ||
| } | ||
| configure(prog, [], assert.fail) | ||
| }) | ||
|
|
||
| if (process.config.variables.use_prefix_to_find_headers) { | ||
| it('use-prefix-to-find-headers build time option - match', function (done) { | ||
| const prog = gyp() | ||
| prog.parseArgv(['dummy_prog', 'dummy_script']) | ||
|
|
||
| prog.spawn = function (program, args) { | ||
| for (let i = 0; i < args.length; i++) { | ||
| const nodedir = process.config.variables.node_prefix | ||
| if (checkTargetPath(nodedir, args[i])) { | ||
| return SPAWN_RESULT(done) | ||
| } | ||
| }; | ||
| assert.fail() | ||
| } | ||
| configure(prog, [], assert.fail) | ||
| }) | ||
|
|
||
| it('use-prefix-to-find-headers build time option - no match', function (done) { | ||
| const prog = gyp() | ||
| prog.parseArgv(['dummy_prog', 'dummy_script']) | ||
|
|
||
| prog.spawn = function (program, args) { | ||
| for (let i = 0; i < args.length; i++) { | ||
| const nodedir = process.config.variables.node_prefix | ||
| if (checkTargetPath(nodedir, args[i])) { | ||
| assert.fail() | ||
| } | ||
| }; | ||
| return SPAWN_RESULT(done) | ||
| } | ||
| configure2(prog, [], assert.fail) | ||
| }) | ||
|
|
||
| it('use-prefix-to-find-headers build time option, target specified', function (done) { | ||
| const prog = gyp() | ||
| prog.parseArgv(['dummy_prog', 'dummy_script', '--target=8.0.0']) | ||
|
|
||
| prog.spawn = function (program, args) { | ||
| for (let i = 0; i < args.length; i++) { | ||
| const nodedir = process.config.variables.node_prefix | ||
| if (checkTargetPath(nodedir, args[i])) { | ||
| assert.fail() | ||
| } | ||
| }; | ||
| return SPAWN_RESULT(done) | ||
| } | ||
| configure(prog, [], assert.fail) | ||
| }) | ||
| } | ||
| }) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.