-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Allow build directory to be changed. #919
Conversation
It should be a switch, like |
Planning to merge? Would be great to allow it for tensorflow. |
lib/configure.js
Outdated
|
||
// now write out the config.gypi file to the build/ dir | ||
var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step' | ||
, json = JSON.stringify(config, boolsToString, 2) | ||
log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) | ||
log.verbose(gyp.buildDir + '/' + configFilename, 'writing out config file: %s', configPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this line at 80 columns? I'd break at the the comma, then line up the second argument with the first one.
@peterbraden Can you add a regression test to test/test-addon.js? |
added a very basic test. |
test/test-addon.js
Outdated
t.strictEqual(binding.hello(), 'world') | ||
|
||
// Cleanup | ||
exec('rm -rf foo', t.end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work on Windows. Can you run node-gyp --build_dir=foo clean
?
Naming bikeshed: what about calling it --build-dir
? That's more in line with --dist-url
. (OTOH there's --msvs_version
but that mimics the gyp variable.)
@peterbraden Can you rebase and squash? Thanks. |
Change with `--build-dir` parameter. ie: ``` node-gyp --build-dir=foo rebuild ``` PR nodejs#919 Fixes nodejs#263
Done |
Your test doesn't work, for two reasons: require cache saving "hello_world" and hello.js using the bindings module to load from the existing build directory. So here's a patch to fix your test: diff --git a/test/test-addon.js b/test/test-addon.js
index 4b8bc5e..2816cd1 100644
--- a/test/test-addon.js
+++ b/test/test-addon.js
@@ -7,6 +7,20 @@ var exec = childProcess.exec
var path = require('path')
var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world')
var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js')
+var rimraf = require('rimraf')
+
+function cleanup (dir) {
+ return function teardown (t) {
+ Object.keys(require.cache)
+ .forEach(function (d) {
+ if (d.indexOf(addonPath) == 0)
+ delete require.cache[d]
+ })
+ rimraf(dir, t.end)
+ }
+}
+
+test('build simple addon - setup', cleanup(path.join(addonPath, 'build')))
test('build simple addon', function (t) {
t.plan(3)
@@ -29,6 +43,10 @@ test('build simple addon', function (t) {
proc.stderr.setEncoding('utf-8')
})
+test('build simple addon - teardown', cleanup(path.join(addonPath, 'build')))
+
+test('build with different build dir - setup', cleanup(path.join(addonPath, 'foo')))
+
test('build with different build dir', function(t) {
var cmd = [nodeGyp, 'rebuild', '-C',
addonPath, '--loglevel=verbose', '--build-dir=foo']
@@ -39,7 +57,7 @@ test('build with different build dir', function(t) {
t.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
try {
- var binding = require('hello_world')
+ var binding = require(path.join(addonPath, 'foo/Release/hello.node'))
t.strictEqual(binding.hello(), 'world')
// Cleanup
@@ -52,3 +70,5 @@ test('build with different build dir', function(t) {
proc.stdout.setEncoding('utf-8')
proc.stderr.setEncoding('utf-8')
})
+
+test('build with different build dir - teardown', cleanup(path.join(addonPath, 'foo'))) |
ping @peterbraden |
Change with `--build-dir` parameter. ie: ``` node-gyp --build-dir=foo rebuild ``` PR nodejs#919 Fixes nodejs#263
Change with `--build-dir` parameter. ie: ``` node-gyp --build-dir=foo rebuild ``` PR nodejs#919 Fixes nodejs#263
Sorry, been busy with a new job. Done now, and squashed and rebased. Thanks! |
test/test-addon.js
Outdated
t.strictEqual(binding.hello(), 'world') | ||
|
||
// Cleanup | ||
exec('node-gyp --build-dir=foo clean', t.end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use execFile(process.execPath, [nodeGyp, ...])
here? Calling out to node-gyp risks picking up the version that is on the path, not what's under test.
Aside: I know they're Rod's work but can you wrap lines at 80 columns? Thanks. :-)
Change with `--build-dir` parameter. ie: ``` node-gyp --build-dir=foo rebuild ``` PR nodejs#919 Fixes nodejs#263
Updated, squashed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. CI: https://ci.nodejs.org/view/All/job/nodegyp-test-commit/33/
CI failed on windows, @bnoordhuis could you take a look? |
Test failures on Windows are because the newly introduced |
No. |
I don't think clearing entries from If the fear is contamination of the second test from the first, then perhaps the new test could be in a separate file? Or does |
@peterbraden Are you still interested in pursuing this? From #919 (comment) it sounds like it's almost there, it just needs one or two small fix-ups.
I think tape uses a process-per-file model so that sounds like a good idea. |
Sure, let me try when I have some free time, maybe this weekend. |
I found out the hard way today that tape runs all tests in the same process. I've filed #1123. |
Has this feature been merged into master? I really need it. |
@peterbraden I'd still be interested in this patch if you want to resurrect it :-) |
if @peterbraden or someone else wants to pick this up, please either rebase this or take the code and open a new PR against the current master |
I don't have time for this any more, hopefully someone else can take this on. |
It's with slightly sad eyes that I'm closing this out. I just closed out #263 after no one stepped forward. Thanks anyway, @peterbraden! |
I'm interested in helping to get this issue over the line, is the "tap/tape" thing mentioned above still an issue? What remains to be done here. |
Change with
NODE_GYP_BUILD_DIR
environment variableFixes #263