Building from source now requires node-addon-api in dependencies

If you want to build sharp from source against a globally-installed
libvips then you will now need to add both node-addon-api and
node-gyp to the dependencies section of your package.json file.

The binding.gyp file is "hidden" inside the src directory to
prevent various build and package manager tooling from assuming
that everyone is going to build from source every time.
This commit is contained in:
Lovell Fuller
2023-10-08 15:38:59 +01:00
parent 51e56f994c
commit f7da2e5970
9 changed files with 48 additions and 29 deletions

View File

@@ -3,18 +3,27 @@
'use strict';
const { useGlobalLibvips, globalLibvipsVersion, log, gypRebuild } = require('../lib/libvips');
const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
const buildFromSource = (msg) => {
log(msg);
log('Attempting to build from source via node-gyp');
try {
require('node-gyp');
require('node-addon-api');
log('Found node-addon-api');
} catch (err) {
log('You might need to install node-gyp');
log('Please add node-addon-api to your dependencies');
return;
}
try {
const gyp = require('node-gyp');
log(`Found node-gyp version ${gyp().version}`);
} catch (err) {
log('Please add node-gyp to your dependencies');
return;
}
log('See https://sharp.pixelplumbing.com/install#building-from-source');
const status = gypRebuild();
const status = spawnRebuild();
if (status !== 0) {
process.exit(status);
}