dll-copy.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2013 Lovell Fuller and others.
  2. // SPDX-License-Identifier: Apache-2.0
  3. 'use strict';
  4. const fs = require('fs');
  5. const path = require('path');
  6. const libvips = require('../lib/libvips');
  7. const platform = require('../lib/platform');
  8. const minimumLibvipsVersion = libvips.minimumLibvipsVersion;
  9. const platformAndArch = platform();
  10. if (platformAndArch.startsWith('win32')) {
  11. const buildReleaseDir = path.join(__dirname, '..', 'build', 'Release');
  12. libvips.log(`Creating ${buildReleaseDir}`);
  13. try {
  14. libvips.mkdirSync(buildReleaseDir);
  15. } catch (err) {}
  16. const vendorLibDir = path.join(__dirname, '..', 'vendor', minimumLibvipsVersion, platformAndArch, 'lib');
  17. libvips.log(`Copying DLLs from ${vendorLibDir} to ${buildReleaseDir}`);
  18. try {
  19. fs
  20. .readdirSync(vendorLibDir)
  21. .filter(function (filename) {
  22. return /\.dll$/.test(filename);
  23. })
  24. .forEach(function (filename) {
  25. fs.copyFileSync(
  26. path.join(vendorLibDir, filename),
  27. path.join(buildReleaseDir, filename)
  28. );
  29. });
  30. } catch (err) {
  31. libvips.log(err);
  32. process.exit(1);
  33. }
  34. }