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

Got node to build on VS2017 #33

Closed
wants to merge 6 commits into from
Closed

Conversation

refack
Copy link
Contributor

@refack refack commented Feb 6, 2017

C:\bin\dev\node\node.exe D:\code\3party\gyp.js\bin\gyp --build Release -Iconfig.gypi -Icommon.gypi -Rnode node.gyp

@refack
Copy link
Contributor Author

refack commented Feb 6, 2017

Squashes my three others (#30, #31, #32)

@@ -31,7 +31,7 @@ describe('gyp.platform.win', () => {

it('should preserve quotes', () => {
assert.deepEqual(
win.adjustLibraries([ '"some path/lib1"', '-l"lib2"',
win.adjustLibraries([ '"some path/lib1"', '-l"lib2"',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE keeps eating this trailing white space...
Let it DIE ;)

@refack
Copy link
Contributor Author

refack commented Feb 6, 2017

> python tools\test.py
[20:17|% 100|+ 1384|-  38]: Done

Copy link
Owner

@indutny indutny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting this! There are some nits that need to be fixed before landing it. Let me know if you have any questions!

Should other PRs be closed, considering that this one includes commits from the others?

@@ -573,17 +583,22 @@ NinjaMain.prototype.vars = function vars() {
cc = 'clang';
cxx = 'clang++';
} else if (process.platform === 'win32') {
ar = 'lib.exe';
ld = 'link.exe';
ar = gyp.bindings.which('lib.exe');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be supplied by setting PATH in environment file, not by using which... Why is it necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔😕
Conceptually you should right, but it failed for me (I have multiple link.exe in my path, and ninja used the wrong one), even though environment.x64 was generated correctly.
If I fix this somehow else, a bunch of stuff can be skipped.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the point of environment files. If it doesn't work - would you mind posting results of which link.exe and the environment file itself?

@@ -660,6 +675,7 @@ NinjaMain.prototype.hostVars = function hostVars(target) {
main.declare('ld_host', ld);
main.declare('ldxx_host', ldxx);
main.declare('ar_host', ar);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous change.

@@ -140,6 +140,7 @@ Ninja.prototype.expand = function expand(p, productDir) {
p = p.replace(/\$!INTERMEDIATE_DIR/g, intDir);
}

p = p.replace(/(\.\.[\\\/])\$\|CONFIGURATION_NAME/g, `$1${this.configDir}`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly gets there in p and how? Why does it have ../ in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (faulty) use case in icu-generic.gyp assumes it knows where the output is base on configuration and calles for

'-P', '../../<(CONFIGURATION_NAME)'

My line assumes that path manipulation (../) with CONFIGURATION_NAME actually want the configuration dir, not just name.
So we get ../../out/Release and not just ../../Release.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it work with regular GYP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voodoo
MSVS at least, resolves paths for actions from the dir of the project file.
I think in our case path resolution for actions start at base of build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, just managed to run gyp -fninja for msvs. Same place is broken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const actionRule = action.action_name + '_' + this.index;
const safeActionName = action.action_name.replace(/\s/g, '_');
global.action_names = (global.action_names || {});
const nameAtConfig = global.action_names[this.config] || (global.action_names[this.config] = {});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

80 column limit? Does it pass make lint?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also just use make format to fix it.

@@ -395,7 +396,12 @@ Ninja.prototype.actions = function actions() {

let res = [];
list.forEach((action) => {
const actionRule = action.action_name + '_' + this.index;
const safeActionName = action.action_name.replace(/\s/g, '_');
global.action_names = (global.action_names || {});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should store action_names in some JS instance, perhaps NinjaMain. Using global is a no-go here. Sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP (although gyp.js is a command line tool, not a service ;) ).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an npm module first of all! :)

@@ -239,7 +236,7 @@ function linkerFlags(linker) {
if (stack_reserve_size) {
let stack_commit_size = linker.StackCommitSize || '';
if (stack_commit_size) stack_commit_size = ',' + stack_commit_size;
ldflags.push('/STACK' + stack_reserve_size + stack_commit_size);
ldflags.push('/STACK:' + stack_reserve_size + stack_commit_size);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not me, the linker wan't happy.

@@ -42,3 +43,5 @@ exports.log = function log(message) {
exports.error = function error(message) {
process.stderr.write(message + '\n');
};

exports.which = (cmd, opt) => `"${which(cmd, opt)}"`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not use this.

if (version === 'auto' && env['VS100COMNTOOLS'] || version === '2010') {
version = '2010';
tools = path.join(env.VS120COMNTOOLS, '..', '..');
function tryVS7() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these functions be hoisted out of resolveDevEnvironment?

win.setEnvironment = function setEnvironment(target_arch) {
const lines = win.resolveDevEnvironment(target_arch);
lines.forEach(l => {
const kv = l.split('=');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could any of env vars have several =?

const lines = win.resolveDevEnvironment(target_arch);
lines.forEach(l => {
const kv = l.split('=');
process.env[kv[0]] = kv[1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's return object instead of modifying global state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted this for the which later.... So pending that.

@refack
Copy link
Contributor Author

refack commented Feb 7, 2017

Found a way to get rid of all the which (which apparently didn't even solve my problem)...

@refack
Copy link
Contributor Author

refack commented Feb 7, 2017

Got rid of the whole which commit.
Instead I use ninjaWrap much more

// TODO(indutny): escape quotes in res
return `cmd.exe /s /c "${res}"`;
const wrap = gyp.platform.win.ninjaWrap;
return `${wrap} powershell -Command ${res.replace(/ & /g, ' ; ')}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

powershell is way more consistent with compound commands (e.g. {cd; xx.exe; copy xx})

win.genEnvironment = function genEnvironment(outDir, target_arch) {
const env = win.resolveDevEnvironment(target_arch);
const envBlock = Object.keys(env)
// .filter(key => key.match(IMPORTANT_VARS))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking all, less complex, maybe even works better...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the filter out, yes?
Just look at what vcvarscmd.bat adds

@refack
Copy link
Contributor Author

refack commented Feb 7, 2017

> python tools\test.py
[19:55|% 100|+ 1381|-  41]: Done

I don't know what's up with that 3 extra fails, but still...

Copy link
Owner

@indutny indutny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few more comments. Moving in the right direction! Thank you

@@ -8,6 +8,7 @@ const execSync = gyp.bindings.execSync;
const path = gyp.bindings.path;
const process = gyp.bindings.process;

const actionNames = {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still it is global here 😉 It should live in NinjaMain or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's module scope, I thought it would be even cleaner, but sure.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it should be per-instance not per-application. That's my point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha

const ninjaWrap = `ninja -t msvc ${envFile}--`;
win.setupNinjaWrapper = function (target_arch) {
const envFile = win.getEnvFileName(target_arch);
this.ninjaWrap = `ninja -t msvc -e ${envFile} --`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global change again 😉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could return a function instead.

win.genEnvironment = function genEnvironment(outDir, target_arch) {
const env = win.resolveDevEnvironment(target_arch);
const envBlock = Object.keys(env)
// .filter(key => key.match(IMPORTANT_VARS))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it.

targetDict,
ninjas,
config: this.config,
actionNames,
Copy link
Contributor Author

@refack refack Feb 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trickling these two into every Ninja

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, true. Could we use actionNames: actionNames here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you like "Object literals Shorthand property names" that's even ES2015

@refack
Copy link
Contributor Author

refack commented Feb 9, 2017

I added another commit with some more windows black magic for finding vs2017 in restricted environments.

@refack refack force-pushed the master branch 3 times, most recently from e2e0ace to e267594 Compare February 10, 2017 23:09
@refack
Copy link
Contributor Author

refack commented Feb 13, 2017

Would you consider adding this as a dep?

@indutny
Copy link
Owner

indutny commented Feb 15, 2017

That sounds good to me!

.gitignore Outdated
@@ -2,3 +2,4 @@ node_modules/
npm-debug.log
out/
coverage/
tools/*.exe
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed, right?

@@ -140,6 +143,8 @@ Ninja.prototype.expand = function expand(p, productDir) {
p = p.replace(/\$!INTERMEDIATE_DIR/g, intDir);
}

// First one is in order to outsmart silly GYP file writers
p = p.replace(/(\.\.[\\\/])+\$\|CONFIGURATION_NAME/g, productDir);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really afraid of doing this. Could we have a test case for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will write some

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote one, but it really concocted...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so what was the exact problem? Which path did it get here, and what was the right path to expect?

Copy link
Contributor Author

@refack refack Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the GYP is:

{
              # build final .dat -> .obj
              'action_name': 'genccode',
              'inputs': [ '<(SHARED_INTERMEDIATE_DIR)/icutmp/icudt<(icu_ver_major)<(icu_endianness).dat' ],
              'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/icudt<(icu_ver_major)<(icu_endianness)_dat.obj' ],
              'action': [ '../../<(CONFIGURATION_NAME)/genccode',
                         '-o',
                         '-d', '<(SHARED_INTERMEDIATE_DIR)/',
                         '-n', 'icudata',
                         '-e', 'icusmdt<(icu_ver_major)',
                         '<@(_inputs)' ],
}

The result (pre patch) is:

rule genccode
  command = cmd.exe$ /s$ /c$ "cd$ ..\..\tools\icu$ &$ ..\..\Release\genccode$ $
    -o$ -d$ ..\..\out\Release\gen\$ -n$ icudata$ -e$ icusmdt58$ $
    ..\..\out\Release\gen\icutmp\icudt58l.dat"

They are trying to reach the output dir, but the path voodoo fails, ..\..\Release\genccode is not there, it's at ..\..\out\Release\genccode

so after patch:

rule genccode
  command = cmd.exe$ /s$ /c$ "cd$ ..\..\tools\icu$ &$ $
    ..\..\out\Release\genccode$ -o$ -d$ ..\..\out\Release\gen\$ -n$ icudata$ $
    -e$ icusmdt58$ ..\..\out\Release\gen\icutmp\icudt58l.dat"

I made a PR to fix the root nodejs/node#11217

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this should not work on Unixes either as it is right now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with ninja

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because other than ninja the other generated output goes in the root dir, and artifacts go in .../node/Release/... or ..../node/Debug/... and so ../../ in the path voodoo is base of root source (.../node/)

const ninja = new Ninja({
index: index,
index,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it as it is.

targetDict,
ninjas,
config: this.config,
actionNames,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, true. Could we use actionNames: actionNames here?

return ret.find(v => v[0] === maxVer)[1];
}

win._forTesting = {tryVS7_powershell, tryVS7_CSC, tryVS7_registry};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess they can be just put in exports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete

}
const env = lines.reduce((s, l) => {
const kv = l.split('=');
s[kv[0]] = kv[1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep only important lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who are we to judge, newer version of VS might add more variables (actually I think they did in 2017), the VsDevCmd.bat runs for almost 20 seconds to setup the ENV, it probably knows what it's doing... and anyway ninja does some more environment voodoo with the -t msvs -e xxx wrapper

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't want to get any unwanted extras from default global env variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do a post - pre delta calculation. I use some of these delta file my day2day dev environment.

@@ -409,67 +392,164 @@ win.getOSBits = function getOSBits() {
return 32;
};

win.genEnvironment = function genEnvironment(outDir, version, arch) {
function tryVS7_powershell() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case? Considering that all of these functions are prefixed with tryVS7, should we put them in win/vs7.js folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm moving them into get-vs2017-path

lib/gyp.js Outdated
@@ -358,7 +358,7 @@ gyp.main = function main(args, extra) {
gyp_binary: args[0],
home_dot_gyp: homeDotGyp,
root_targets: options.root_targets,
target_arch: cmdlineDefaultVariables['target_arch'] || ''
target_arch: cmdlineDefaultVariables['target_arch'] || 'ia32'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about why is this necessary. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So It won't be necessary in every access to conf['target_arch'] later

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put process.arch here then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, why not

@refack refack force-pushed the master branch 2 times, most recently from e9dee6e to bd98d01 Compare February 15, 2017 23:36
lib/gyp.js Outdated
@@ -358,7 +358,7 @@ gyp.main = function main(args, extra) {
gyp_binary: args[0],
home_dot_gyp: homeDotGyp,
root_targets: options.root_targets,
target_arch: cmdlineDefaultVariables['target_arch'] || ''
target_arch: cmdlineDefaultVariables['target_arch'] || 'ia32'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put process.arch here then?

if (process.platform === 'win32') {
const getVS2017Path = require('get-vs2017-path').getVS2017Path;
exports.getVS2017Path = function (hostBits, target_arch) {
return getVS2017Path(hostBits, target_arch, exports);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the last argument here for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I name it "require less" I use your external bindings (execSync, log, and path)

targetDict: this.targetDicts[target].configurations[this.config],
ninjas: ninjas,
config: this.config
target,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I mind that much, but I still have hopes for transpiling it to ES5 with a minimal AST transformation. Let's keep these changes out for now.

}
const env = lines.reduce((s, l) => {
const kv = l.split('=');
s[kv[0]] = kv[1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't want to get any unwanted extras from default global env variables.

@refack refack force-pushed the master branch 2 times, most recently from 50cfd89 to 17e5b8a Compare February 16, 2017 01:52
@refack
Copy link
Contributor Author

refack commented Feb 21, 2017

we could always test build node with 'icu_small': 'false',

// TODO(indutny): escape quotes in res
return `cmd.exe /s /c "${res}"`;
const nw = gyp.platform.win.getNinjaWrapper(this.targetArch);
return `${nw} cmd.exe /s /c "${res}"`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lost this at some point during rebasing. Just brought it back...

Copy link
Contributor Author

@refack refack Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RE your TODO: the /s switch takes care of all your " worries.

/S      behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So res = '" "' works? This will look like nw cmd.exe /s /c " " " "...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. also res = 'xxx "yyy" zzz'.
as long as res is well formed

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So who will separate spaces?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if res = 'gaga" "lala'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that's well formed (in the sense pasting gaga" "lala in a windows console works), but if it is, it'll work.
Thank god it's not VBScript

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd /s /c "xxxxxxxxxx" was meant to be like bash -- xxxxxxxxxxxxxx

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaah, ok then :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@refack
Copy link
Contributor Author

refack commented Feb 21, 2017

P.S. https://ci.appveyor.com/project/refack/get-vs2017-path for it to pass, it has to pass gyp.js's test suite.

@indutny
Copy link
Owner

indutny commented Feb 23, 2017

Sorry for delay.

I spent some additional time on this and now I realize that there is a problem with using external get-vs2017-path module.

The bindings file that we have in this repo is meant as an abstraction for things that are not provided by JS in general. The idea here is that gyp.js could potentially run on duktape with few C functions added to make it work on all platforms.

I'm afraid, this won't work too well for external module. Do you think there is still a chance of having it here?

@refack
Copy link
Contributor Author

refack commented Feb 23, 2017

I'm ahead of you. Check out line 51 in binding.js, I take all dependencies from you (only need path and execSync)
It's a very only Design Pattern, called "Dependency Injection" (node.js in general used the "Registry" pattern with require())

@refack
Copy link
Contributor Author

refack commented Feb 23, 2017

P.S. IMHO ducktapeing is a bit of overkill... making node a dependency for node building sound sane. Also gpy.js would save a ton of trouble with just node-gyp as is. But no harm in not causing too much incompatibilities.

Copy link
Owner

@indutny indutny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few very last nits. Good work, mate!

// TODO(indutny): escape quotes in res
return `cmd.exe /s /c "${res}"`;
const nw = gyp.platform.win.getNinjaWrapper(this.targetArch);
return `${nw} cmd.exe /s /c "${res}"`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So res = '" "' works? This will look like nw cmd.exe /s /c " " " "...

/******************* late require *******************/
const getter = require('get-vs2017-path');
// We just need all the binding to be set on `exports`
getter.setBindings(exports);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right!

@@ -42,3 +43,15 @@ exports.log = function log(message) {
exports.error = function error(message) {
process.stderr.write(message + '\n');
};

Object.defineProperty(exports, 'win', {get() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be a bit more verbose: get: function get() {. Also, please put it on separate line and indent properly.

@@ -42,3 +43,15 @@ exports.log = function log(message) {
exports.error = function error(message) {
process.stderr.write(message + '\n');
};

Object.defineProperty(exports, 'win', {get() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be a bit more verbose: get: function get() {. Also, please put it on separate line and indent properly.

@@ -42,3 +43,15 @@ exports.log = function log(message) {
exports.error = function error(message) {
process.stderr.write(message + '\n');
};

Object.defineProperty(exports, 'win', {get() {
/******************* late require *******************/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// instead of /* */

lib/gyp.js Outdated
@@ -358,7 +358,8 @@ gyp.main = function main(args, extra) {
gyp_binary: args[0],
home_dot_gyp: homeDotGyp,
root_targets: options.root_targets,
target_arch: cmdlineDefaultVariables['target_arch'] || ''
target_arch: cmdlineDefaultVariables['target_arch']
|| gyp.bindings.process.arch
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| at the end of previous line.

return envFile;
};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this extra whitespace.

@refack
Copy link
Contributor Author

refack commented Feb 23, 2017

TODO: write and integration for GitHub code reviews and WebStorm 😉 initial GraphQL gist

@refack
Copy link
Contributor Author

refack commented Feb 23, 2017

Done

@refack refack force-pushed the master branch 2 times, most recently from e552dbf to f98081e Compare February 24, 2017 16:41
@refack
Copy link
Contributor Author

refack commented Feb 24, 2017

I renamed my package, and I'm planning on eating more of your Windows specific code. My goal is to generate window.ninja that has all the win-kruft, and that you could just #include in the generated build.ninja

@indutny
Copy link
Owner

indutny commented Mar 17, 2017

@refack yikes, sorry! I forgot about this. Would you care to rebase it? This should mostly involve renaming files from lib/ to src/. Many thanks!

@refack
Copy link
Contributor Author

refack commented Mar 17, 2017

Sure.
BTW: vote for me at nodejs/node#11852

@indutny
Copy link
Owner

indutny commented Mar 17, 2017

@refack what kind of vote do you need? 😉

@refack
Copy link
Contributor Author

refack commented Mar 17, 2017

review or say LGTW (vs. the "competing" nodejs/node#11867)

@refack
Copy link
Contributor Author

refack commented Mar 17, 2017

Was very easy git is magic.

@indutny
Copy link
Owner

indutny commented Mar 17, 2017

Landed in 259294b, thank you for awesome work!

@indutny indutny closed this Mar 17, 2017
@AndrewPardoe
Copy link

The officially supported vswhere tool is now available as part of the install starting today with Visual Studio 15.2 preview 2: https://blogs.msdn.microsoft.com/heaths/2017/04/21/vswhere-is-now-installed-with-visual-studio-2017/. I hope this helps your scenario.

This doesn't fix all the existing installs of VS 2017 but going forward you can now detect the VS install locations and whether C++ tools are available from a scripted environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants