From c8644f5dbfa03bfaa0afaf947121c4ac7bf718a4 Mon Sep 17 00:00:00 2001 From: Kylart Date: Sun, 29 Mar 2020 18:52:46 +0200 Subject: [PATCH] Can now ship windows build with libssl and libcrypto 1.1 --- .gitignore | 1 + scripts/moveLibs.js | 41 +++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index dde3e84..09c42dc 100644 --- a/.gitignore +++ b/.gitignore @@ -38,5 +38,6 @@ bindings/build # External libs binaries public/*.dylib +public/*.dll public/mpv/* !public/mpv/.gitkeep \ No newline at end of file diff --git a/scripts/moveLibs.js b/scripts/moveLibs.js index b31dbab..5be54f9 100644 --- a/scripts/moveLibs.js +++ b/scripts/moveLibs.js @@ -1,22 +1,31 @@ -const { readdirSync, copyFileSync } = require('fs') -const { join } = require('path') +const { homedir } = require('os') +const { copyFileSync } = require('fs') +const { join, basename } = require('path') const PUBLIC_DIR = join(__dirname, '..', 'public') -const BINDINGS_BUILD_DIR = join(__dirname, '..', 'bindings', 'build', 'Release') -const FILE_NAME = { - darwin: 'libtorrent-rasterbar.10.dylib', - win32: 'libtorrent-rasterbar.dll' -}[process.platform] || 'libtorrent-rasterbar.so' +function moveToPublic (filepath) { + console.log(`[KawAnime] Copying ${filepath} to public directory.`) -readdirSync(BINDINGS_BUILD_DIR) - .forEach((file) => { - if (file !== FILE_NAME) return + copyFileSync( + filepath, + join(PUBLIC_DIR, basename(filepath)) + ) +} - console.log(`[KawAnime] Moving ${file} to public directory.`) +function linux () { + // TODO +} - copyFileSync( - join(BINDINGS_BUILD_DIR, file), - join(PUBLIC_DIR, file) - ) - }) +function windows () { + const sys32Path = join(homedir().split('\\')[0], 'Windows', 'System32') + const requiredDlls = [ + 'libcrypto-1_1-x64.dll', + 'libssl-1_1-x64.dll' + ].map((dll) => join(sys32Path, dll)) + + requiredDlls.forEach(moveToPublic) +} + +if (process.platform === 'win32') windows() +else linux()