target -> targetArch because there will be targetPlatform
This commit is contained in:
parent
d57cd94f78
commit
87c8b646eb
@ -1,26 +1,26 @@
|
||||
import { localPlace, remotePlace } from './places.js';
|
||||
import { platform, targets } from './system.js';
|
||||
import { platform, targetArchs } from './system.js';
|
||||
import build from './build.js';
|
||||
import chalk from 'chalk';
|
||||
import patchesJson from '../patches/patches.json';
|
||||
import upload from './upload.js';
|
||||
import { version } from '../package.json';
|
||||
|
||||
function isBrokenBuild (nodeVersion, target) {
|
||||
function isBrokenBuild (nodeVersion, targetArch) {
|
||||
if (/^v?0/.test(nodeVersion) &&
|
||||
/^arm/.test(target)) return true;
|
||||
/^arm/.test(targetArch)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function main () {
|
||||
for (const nodeVersion in patchesJson) {
|
||||
for (const target of targets) {
|
||||
if (isBrokenBuild(nodeVersion, target)) continue;
|
||||
const local = localPlace({ arch: target, nodeVersion, platform, version });
|
||||
console.error(`> ${chalk.yellow('Building')} ${nodeVersion}-${target}`);
|
||||
await build({ copyDest: local, nodeVersion, target });
|
||||
for (const targetArch of targetArchs) {
|
||||
if (isBrokenBuild(nodeVersion, targetArch)) continue;
|
||||
const local = localPlace({ arch: targetArch, nodeVersion, platform, version });
|
||||
console.error(`> ${chalk.yellow('Building')} ${nodeVersion}-${targetArch}`);
|
||||
await build({ copyDest: local, nodeVersion, targetArch });
|
||||
console.error(`> ${chalk.yellow('Uploading')} ${local}`);
|
||||
const remote = remotePlace({ arch: target, nodeVersion, platform, version });
|
||||
const remote = remotePlace({ arch: targetArch, nodeVersion, platform, version });
|
||||
await upload(local, remote, version);
|
||||
}
|
||||
}
|
||||
|
||||
14
lib/build.js
14
lib/build.js
@ -12,18 +12,18 @@ const buildPath = tempPath();
|
||||
const nodePath = path.join(buildPath, 'node');
|
||||
const patchesPath = path.resolve(__dirname, '../patches');
|
||||
|
||||
async function compileOnWindows (target) {
|
||||
async function compileOnWindows (targetArch) {
|
||||
const args = [];
|
||||
args.push('/c', 'vcbuild.bat', target, 'nosign');
|
||||
args.push('/c', 'vcbuild.bat', targetArch, 'nosign');
|
||||
await spawn('cmd', args,
|
||||
{ stdio: 'inherit', cwd: nodePath });
|
||||
return path.join(nodePath, 'Release/node.exe');
|
||||
}
|
||||
|
||||
async function compileOnUnix (target) {
|
||||
async function compileOnUnix (targetArch) {
|
||||
const args = [];
|
||||
const cpu = { x86: 'ia32', x64: 'x64',
|
||||
armv6: 'arm', armv7: 'arm' }[target];
|
||||
armv6: 'arm', armv7: 'arm' }[targetArch];
|
||||
args.push('--dest-cpu', cpu);
|
||||
await spawn('./configure', args,
|
||||
{ stdio: 'inherit', cwd: nodePath });
|
||||
@ -33,7 +33,7 @@ async function compileOnUnix (target) {
|
||||
}
|
||||
|
||||
export default async function build (opts) {
|
||||
const { copyDest, nodeVersion, target } = opts;
|
||||
const { copyDest, nodeVersion, targetArch } = opts;
|
||||
await rimraf(buildPath);
|
||||
await mkdirp(buildPath);
|
||||
|
||||
@ -55,9 +55,9 @@ export default async function build (opts) {
|
||||
|
||||
let output;
|
||||
if (windows) {
|
||||
output = await compileOnWindows(target);
|
||||
output = await compileOnWindows(targetArch);
|
||||
} else {
|
||||
output = await compileOnUnix(target);
|
||||
output = await compileOnUnix(targetArch);
|
||||
}
|
||||
|
||||
await mkdirp(path.dirname(copyDest));
|
||||
|
||||
@ -29,7 +29,7 @@ export function toFancyArch (arch) {
|
||||
return arch;
|
||||
}
|
||||
|
||||
function getArmHost () {
|
||||
function getArmHostArch () {
|
||||
const cpu = fs.readFileSync('/proc/cpuinfo', 'utf8');
|
||||
if (cpu.indexOf('vfpv3') >= 0) return 'armv7';
|
||||
let name = cpu.split('model name')[1];
|
||||
@ -39,28 +39,25 @@ function getArmHost () {
|
||||
return 'armv6';
|
||||
}
|
||||
|
||||
function getHost () {
|
||||
const host = process.arch;
|
||||
if (host === 'arm') return getArmHost();
|
||||
return toFancyArch(host);
|
||||
function getHostArch () {
|
||||
const { arch } = process;
|
||||
if (arch === 'arm') return getArmHostArch();
|
||||
return toFancyArch(arch);
|
||||
}
|
||||
|
||||
function getTargets () {
|
||||
const host = getHost();
|
||||
if (host === 'x64') return [ 'x64', 'x86' ];
|
||||
function getTargetArchs () {
|
||||
const arch = getHostArch();
|
||||
if (arch === 'x64') return [ 'x64', 'x86' ];
|
||||
// TODO find a way to crosscompile for armv6 on armv7
|
||||
return [ host ];
|
||||
return [ arch ];
|
||||
}
|
||||
|
||||
function getKnownArchs () {
|
||||
const host = getHost();
|
||||
const archs = [ 'x64', 'x86', 'armv6', 'armv7' ];
|
||||
if (archs.indexOf(host) < 0) throw new Error(`Unknown arch ${host}`);
|
||||
return archs;
|
||||
return [ 'x64', 'x86', 'armv6', 'armv7' ];
|
||||
}
|
||||
|
||||
export const abi = getAbi();
|
||||
export const platform = getPlatform();
|
||||
export const host = getHost();
|
||||
export const targets = getTargets();
|
||||
export const hostArch = getHostArch();
|
||||
export const targetArchs = getTargetArchs();
|
||||
export const knownArchs = getKnownArchs();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user