From dcd1392a85a35e5b610d95d9bd9225ca3b39c999 Mon Sep 17 00:00:00 2001 From: Taka Kojima Date: Sat, 1 Oct 2016 07:54:14 -0400 Subject: [PATCH] Allow platform, arch and arm_version to be overridden (#581) Aids cross-compilation --- binding.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/binding.js b/binding.js index 9a2c8f9d..f56a9cfe 100644 --- a/binding.js +++ b/binding.js @@ -17,6 +17,16 @@ var minimumLibvipsVersion = process.env.npm_package_config_libvips || require('. var vipsHeaderPath = path.join(__dirname, 'include', 'vips', 'vips.h'); +var platform = process.env.npm_config_platform || process.platform; + +var arch = process.env.npm_config_arch || process.arch; +var arm_version = process.env.npm_config_armv || process.config.variables.arm_version; + +if (arch === 'arch64' || arch === 'armhf') { + arch = 'arm'; + if (arch === 'arch64') arm_version = '8'; +} + // -- Helpers // Does this file exist? @@ -47,9 +57,9 @@ var unpack = function(tarPath, done) { }; var platformId = function() { - var id = [process.platform, process.arch].join('-'); - if (process.arch === 'arm') { - switch(process.config.variables.arm_version) { + var id = [platform, arch].join('-'); + if (arch === 'arm') { + switch(arm_version) { case '8': id = id + 'v8'; break; @@ -79,7 +89,7 @@ module.exports.download_vips = function() { // Has vips been installed locally? if (!isFile(vipsHeaderPath)) { // Ensure Intel 64-bit or ARM - if (process.arch === 'ia32') { + if (arch === 'ia32') { error('Intel Architecture 32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/'); } // Ensure glibc >= 2.15