Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
refack committed Feb 7, 2017
1 parent 90a903e commit 30e875e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions lib/gyp/generator/ninja/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ Ninja.prototype.actionCmd = function actionCmd(base, toBase, cmds) {
if (this.flavor !== 'win32')
return res;

// TODO(indutny): escape quotes in res
return `${gyp.platform.win.ninjaWrap} powershell -Command ${res.replace(/ & /g, ' ; ')}`;
const wrap = gyp.platform.win.ninjaWrap;
return `${wrap} powershell -Command ${res.replace(/ & /g, ' ; ')}`;
};

Ninja.prototype.copies = function copies() {
Expand Down Expand Up @@ -420,7 +420,9 @@ Ninja.prototype.actions = function actions() {
res = res.concat(outputs);

if (action.process_outputs_as_sources === '1') {
this.targetDict.sources = (this.targetDict.sources || []).concat(action.outputs);
let trg = this.targetDict;
trg.sources = trg.sources || [];
trg.sources = trg.sources.concat(action.outputs);
}

this.n.build(actionRule, outputs, inputs, {
Expand Down
18 changes: 11 additions & 7 deletions lib/gyp/platform/win.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,17 @@ win.getOSBits = function getOSBits() {

function tryVS7(hostBits, target_arch) {
try {
const psFile = path.join(__dirname, '..', '..', '..', 'tools', 'Get-VSConfig.ps1');
const psFile = path.join(__dirname,
'..', '..', '..', 'tools', 'Get-VSConfig.ps1');
const vsSetupRaw = gyp.bindings.execSync(`powershell ${psFile}`).toString();
if (!vsSetupRaw) return;
const vsSetup = vsSetupRaw.split(/[\r|\n]/g).reduce((s, l) => {
const lParts = l.split(': ');
if (lParts.length > 1) s[lParts[0]] = lParts[1];
return s;
}, {});
const VsDevCmd = path.join(vsSetup.InstallationPath, 'Common7', 'Tools', 'VsDevCmd.bat');
const VsDevCmd = path.join(vsSetup.InstallationPath,
'Common7', 'Tools', 'VsDevCmd.bat');
const argArch = target_arch === 'x64' ? 'amd64' : 'x86';
const argHost = hostBits === 64 ? 'amd64' : 'x86';
return `${VsDevCmd} -arch=${argArch} -host_arch=${argHost} -no_logo`;
Expand Down Expand Up @@ -446,7 +448,9 @@ function findOldVcVarsFile(hostBits, target_arch) {
if (hostBits === 64)
vcEnvCmd = '"' + path.join(tools, 'VC', 'vcvarsall.bat') + '" amd64_x86';
else
vcEnvCmd = '"' + path.join(tools, 'Common7', 'Tools', 'vsvars32.bat') + '"';
vcEnvCmd = '"'
+ path.join(tools, 'Common7', 'Tools', 'vsvars32.bat')
+ '"';
} else if (target_arch === 'x64') {
let arg;
if (hostBits === 64)
Expand All @@ -463,8 +467,8 @@ function findOldVcVarsFile(hostBits, target_arch) {
win.resolveDevEnvironment = function resolveDevEnvironment(target_arch) {
const hostBits = win.getOSBits();

const vcEnvCmd = tryVS7(hostBits, target_arch)
|| findOldVcVarsFile(hostBits, target_arch);
const vcEnvCmd = tryVS7(hostBits, target_arch) ||
findOldVcVarsFile(hostBits, target_arch);
let lines = [];
try {
lines = gyp.bindings.execSync(`${vcEnvCmd} & set`, {env: {}}).toString()
Expand All @@ -481,8 +485,8 @@ win.resolveDevEnvironment = function resolveDevEnvironment(target_arch) {
return env;
};

const IMPORTANT_VARS =
/^include|lib|libpath|path|pathext|systemroot|temp|tmp$/i;
// const IMPORTANT_VARS =
// /^include|lib|libpath|path|pathext|systemroot|temp|tmp$/i;

win.genEnvironment = function genEnvironment(outDir, target_arch) {
const env = win.resolveDevEnvironment(target_arch);
Expand Down
8 changes: 5 additions & 3 deletions test/platform-win-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,11 @@ describe('gyp.platform.win', () => {
assert(env, 'didn\'t get ENVIRONMENT :(');
const COMNTOOLS = Object.keys(env).find(k => k.includes('COMNTOOLS'));
assert(COMNTOOLS, 'didn\'t get COMNTOOLS :(');
if (COMNTOOLS === 'VS150COMNTOOLS'){
if (COMNTOOLS === 'VS150COMNTOOLS') {
assert.equal(env['VSCMD_ARG_TGT_ARCH'], 'x64');
assert.equal(env['VisualStudioVersion'], '15.0');
assert(env['__VSCMD_PREINIT_PATH'], 'Last env var should be __VSCMD_PREINIT_PATH');
assert(env['__VSCMD_PREINIT_PATH'],
'Last env var should be __VSCMD_PREINIT_PATH');
}
});

Expand All @@ -248,7 +249,8 @@ describe('gyp.platform.win', () => {
if (COMNTOOLS === 'VS150COMNTOOLS') {
assert.equal(env['VSCMD_ARG_TGT_ARCH'], 'x86');
assert.equal(env['VisualStudioVersion'], '15.0');
assert(env['__VSCMD_PREINIT_PATH'], 'Last env var should be __VSCMD_PREINIT_PATH');
assert(env['__VSCMD_PREINIT_PATH'],
'Last env var should be __VSCMD_PREINIT_PATH');
}
});
});
Expand Down

0 comments on commit 30e875e

Please sign in to comment.