You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const os = require('os');
  3. const binBuild = require('bin-build');
  4. const log = require('logalot');
  5. const bin = require('.');
  6. const cpuNum = os.cpus().length;
  7. bin.run(['-version']).then(() => {
  8. log.success('mozjpeg pre-build test passed successfully');
  9. }).catch(error => {
  10. log.warn(error.message);
  11. log.warn('mozjpeg pre-build test failed');
  12. log.info('compiling from source');
  13. let cfgExtras = '';
  14. if (process.platform === 'darwin') {
  15. cfgExtras = 'libpng_LIBS=\'/usr/local/lib/libpng16.a -lz\' --enable-static';
  16. }
  17. const cfg = [
  18. `./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8 ${cfgExtras}`,
  19. `--prefix="${bin.dest()}" --bindir="${bin.dest()}" --libdir="${bin.dest()}"`
  20. ].join(' ');
  21. binBuild.url('https://github.com/mozilla/mozjpeg/releases/download/v3.2/mozjpeg-3.2-release-source.tar.gz', [
  22. 'autoreconf -fiv',
  23. cfg,
  24. `make -j${cpuNum}`,
  25. `make install -j${cpuNum}`
  26. ]).then(() => {
  27. log.success('mozjpeg built successfully');
  28. }).catch(error => {
  29. log.error(error.stack);
  30. });
  31. });