moved thresholds to separate file

This commit is contained in:
igorklopov 2016-08-17 12:09:33 +03:00
parent a3f88a25cc
commit 0751ce466c
2 changed files with 51 additions and 25 deletions

View File

@ -5,6 +5,7 @@ import log from './log.js';
import patchesJson from '../patches/patches.json';
import path from 'path';
import { tempPath } from './temp-path.js';
import thresholds from './thresholds.js';
const windows = process.platform === 'win32';
@ -13,19 +14,13 @@ const nodePath = path.join(buildPath, 'node');
const patchesPath = path.resolve(__dirname, '../patches');
const nodeRepo = 'https://github.com/nodejs/node';
const gitCloneThresholds = {
'ving objects: 0%': 0, 'ving objects: 1%': 1, 'ving objects: 5%': 5, // eslint-disable-line key-spacing
'ving objects: 10%': 10, 'ving objects: 20%': 20, 'ving objects: 40%': 40,
'ving objects: 61%': 60, 'ving objects: 81%': 80, 'deltas: 0%': 98
};
// TODO try cloning bare repo
async function gitClone () {
log.info('Cloning Node.js from GitHub');
const args = [ 'clone', '--progress', nodeRepo, 'node' ];
const promise = spawn('git', args, { cwd: buildPath });
progress(promise.child, gitCloneThresholds);
progress(promise.child, thresholds('clone'));
await promise;
}
@ -45,35 +40,23 @@ async function applyPatches (nodeVersion) {
}
}
const windowsThresholds = {
'http_parser.vcxproj ->': 1, 'openssl.vcxproj ->': 3,
'icudata.vcxproj ->': 13, 'hydrogen-representation-changes.cc': 20,
'interface-descriptors-x64.cc': 30, 'v8_base_0.vcxproj ->': 44,
'build\\Release\\mksnapshot.lib': 57, 'mksnapshot.vcxproj ->': 69,
'node\\Release\\node.exp': 85, 'cctest.vcxproj ->': 97
};
async function compileOnWindows (targetArch) {
async function compileOnWindows (nodeVersion, targetArch) {
const args = [];
args.push('/c', 'vcbuild.bat', targetArch, 'nosign');
const promise = spawn('cmd', args, { cwd: nodePath });
progress(promise.child, windowsThresholds);
progress(promise.child, thresholds('vcbuild', nodeVersion));
await promise;
return path.join(nodePath, 'Release/node.exe');
}
const unixThresholds = {
'v8_base/deps/v8/src/date.o.d.raw': 50
};
async function compileOnUnix (targetArch) {
async function compileOnUnix (nodeVersion, targetArch) {
const args = [];
const cpu = { x86: 'ia32', x64: 'x64',
armv6: 'arm', armv7: 'arm' }[targetArch];
args.push('--dest-cpu', cpu);
await spawn('./configure', args, { cwd: nodePath });
const promise = spawn('make', [], { cwd: nodePath });
progress(promise.child, unixThresholds);
progress(promise.child, thresholds('make', nodeVersion));
await promise;
return path.join(nodePath, 'out/Release/node');
}
@ -90,9 +73,9 @@ export default async function build (
log.info('Compiling Node.js sources');
let output;
if (windows) {
output = await compileOnWindows(targetArch);
output = await compileOnWindows(nodeVersion, targetArch);
} else {
output = await compileOnUnix(targetArch);
output = await compileOnUnix(nodeVersion, targetArch);
}
await mkdirp(path.dirname(local));

43
lib/thresholds.js Normal file
View File

@ -0,0 +1,43 @@
/* eslint-disable key-spacing */
/* eslint-disable no-multi-spaces */
import assert from 'assert';
export default function thresholds (cmd, nodeVersion) {
if (cmd === 'clone') {
return {
'ving objects: 0%': 0, 'ving objects: 1%': 1, 'ving objects: 5%': 5,
'ving objects: 10%': 10, 'ving objects: 20%': 20, 'ving objects: 40%': 40,
'ving objects: 61%': 60, 'ving objects: 81%': 80, 'deltas: 0%': 98
};
} else
if (cmd === 'vcbuild') {
if (/^v?4/.test(nodeVersion)) {
return {
'http_parser.vcxproj ->': 1, 'openssl.vcxproj ->': 3,
'icudata.vcxproj ->': 13, 'hydrogen-representation-changes.cc': 20,
'interface-descriptors-x64.cc': 30, 'v8_base_0.vcxproj ->': 44,
'build\\Release\\mksnapshot.lib': 57, 'mksnapshot.vcxproj ->': 69,
'node\\Release\\node.exp': 85, 'cctest.vcxproj ->': 97
};
} else
if (/^v?6/.test(nodeVersion)) {
return {
'http_parser.vcxproj ->': 1, 'openssl.vcxproj ->': 3,
'icudata.vcxproj ->': 13, 'hydrogen-representation-changes.cc': 20,
'interface-descriptors-x64.cc': 30, 'v8_base_0.vcxproj ->': 44,
'build\\Release\\mksnapshot.lib': 57, 'mksnapshot.vcxproj ->': 69,
'node\\Release\\node.exp': 85, 'cctest.vcxproj ->': 97
};
} else {
return {};
}
} else
if (cmd === 'make') {
return {
'v8_base/deps/v8/src/date.o.d.raw': 50
};
} else {
assert(false);
}
}