mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 02:30:12 +02:00
Install: advanced option to force global libvips #4060
This commit is contained in:
parent
f67228e5ea
commit
579cf93030
@ -12,6 +12,9 @@ Requires libvips v8.15.2
|
||||
[#4048](https://github.com/lovell/sharp/pull/4048)
|
||||
[@ike-gg](https://github.com/ike-gg)
|
||||
|
||||
* Install: add advanced option to force use of a globally-installed libvips.
|
||||
[#4060](https://github.com/lovell/sharp/issues/4060)
|
||||
|
||||
* Expose `bilinear` resizing kernel (and interpolator).
|
||||
[#4061](https://github.com/lovell/sharp/issues/4061)
|
||||
|
||||
|
@ -103,9 +103,14 @@ and on macOS when running Node.js under Rosetta.
|
||||
|
||||
This module will be compiled from source at `npm install` time when:
|
||||
|
||||
* a globally-installed libvips is detected (set the `SHARP_IGNORE_GLOBAL_LIBVIPS` environment variable to skip this), or
|
||||
* a globally-installed libvips is detected, or
|
||||
* when the `npm install --build-from-source` flag is used.
|
||||
|
||||
The logic to detect a globally-installed libvips can be skipped by setting the
|
||||
`SHARP_IGNORE_GLOBAL_LIBVIPS` (never try to use it) or
|
||||
`SHARP_FORCE_GLOBAL_LIBVIPS` (always try to use it, even when missing or outdated)
|
||||
environment variables.
|
||||
|
||||
Building from source requires:
|
||||
|
||||
* C++11 compiler
|
||||
|
File diff suppressed because one or more lines are too long
@ -162,15 +162,21 @@ const pkgConfigPath = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const skipSearch = (status, reason) => {
|
||||
log(`Detected ${reason}, skipping search for globally-installed libvips`);
|
||||
return status;
|
||||
};
|
||||
|
||||
const useGlobalLibvips = () => {
|
||||
if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
|
||||
log('Detected SHARP_IGNORE_GLOBAL_LIBVIPS, skipping search for globally-installed libvips');
|
||||
return false;
|
||||
return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS');
|
||||
}
|
||||
if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
|
||||
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS');
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
if (isRosetta()) {
|
||||
log('Detected Rosetta, skipping search for globally-installed libvips');
|
||||
return false;
|
||||
return skipSearch(false, 'Rosetta');
|
||||
}
|
||||
const globalVipsVersion = globalLibvipsVersion();
|
||||
return !!globalVipsVersion && /* istanbul ignore next */
|
||||
|
@ -66,6 +66,14 @@ describe('libvips binaries', function () {
|
||||
|
||||
delete process.env.SHARP_IGNORE_GLOBAL_LIBVIPS;
|
||||
});
|
||||
it('useGlobalLibvips can be forced via an env var', function () {
|
||||
process.env.SHARP_FORCE_GLOBAL_LIBVIPS = 1;
|
||||
|
||||
const useGlobalLibvips = libvips.useGlobalLibvips();
|
||||
assert.strictEqual(true, useGlobalLibvips);
|
||||
|
||||
delete process.env.SHARP_FORCE_GLOBAL_LIBVIPS;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Build time platform detection', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user