mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 02:30:12 +02:00
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.
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
// Copyright 2013 Lovell Fuller and others.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
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-addon-api');
|
|
log('Found node-addon-api');
|
|
} catch (err) {
|
|
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 = spawnRebuild();
|
|
if (status !== 0) {
|
|
process.exit(status);
|
|
}
|
|
};
|
|
|
|
if (useGlobalLibvips()) {
|
|
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
|
} else if (process.env.npm_config_build_from_source) {
|
|
buildFromSource('Detected --build-from-source flag');
|
|
}
|