diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..9c595a6 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +temp diff --git a/lib/build.js b/lib/build.js index f8f1fe4..ff534d5 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,4 +1,4 @@ -import { arch, platform, targets } from './system.js'; +import { platform, targets } from './system.js'; import chipo from 'child-process-promise'; import chalk from 'chalk'; import { localPath } from './places.js'; @@ -10,6 +10,7 @@ import { version } from '../package.json'; const buildPath = path.resolve(__dirname, '../temp'); const patchesPath = path.resolve(__dirname, '../patches'); +const windows = platform === 'win32'; async function main () { for (const nodeVersion in patchesJson) { @@ -25,7 +26,29 @@ async function main () { [ 'reset', '--hard', nodeVersion ], { stdio: 'inherit', cwd: buildPath + '/node' }); - // const patches = patchesJson[nodeVersion]; + const patches = patchesJson[nodeVersion]; + for (const patch of patches) { + console.log(`> ${chalk.yellow('Applying patch')} ${patch}`); + const patchPath = path.join(patchesPath, patch); + await chipo.spawn('patch', + [ '-p1', '-i', patchPath ], + { stdio: 'inherit', cwd: buildPath + '/node' }); + + const args = []; + if (windows) { + throw new Error('Not implemented TODO'); + } else { + const cpu = { x86: 'ia32', x64: 'x64', + armv6: 'arm', armv7: 'arm' }[target]; + args.push('--dest-cpu', cpu); + await chipo.spawn('./configure', args, + { stdio: 'inherit', cwd: buildPath + '/node' }); + await chipo.spawn('make', + { stdio: 'inherit', cwd: buildPath + '/node' }); + } + + // TODO place to ~/.pkg-cache + } } } } diff --git a/lib/system.js b/lib/system.js index ec3cdc5..9484551 100644 --- a/lib/system.js +++ b/lib/system.js @@ -23,7 +23,7 @@ function getArch () { function getTargets () { // TODO x64, x86 from 'x64'? - return getArch(); + return [ getArch() ]; } export const abi = getAbi();