diff --git a/bindings/index.js b/bindings/index.js index f884b66..4927faa 100644 --- a/bindings/index.js +++ b/bindings/index.js @@ -1,10 +1,3 @@ -/* global __static */ - -// import bindings from './build/Release/kawabinds.node' -import { join } from 'path' - -const bindings = process.env.NODE_ENV === 'development' - ? './build/Release/kawabinds.node' - : join(__static, 'kawabinds', 'kawabinds.node') +import bindings from './build/Release/kawabinds.node' export default bindings diff --git a/collect-dylib-deps.sh b/collect-dylib-deps.sh index c2a7d9a..adc98ec 100755 --- a/collect-dylib-deps.sh +++ b/collect-dylib-deps.sh @@ -10,47 +10,30 @@ copy_deps() { [[ -e $dir/$depname ]] || install -m755 $dep $dir - otool -L $dep | awk '/\/usr\/local.*\.dylib /{print $1}' | while read lib; do + otool -L $dep | awk '/@rpath\/.*\.dylib /{print $1}' | while read lib; do local libname=$(basename $lib) [[ $depname = $libname ]] && continue echo $libname install_name_tool -change $lib @loader_path/$libname $dir/$depname [[ -e $dir/$libname ]] && continue - install -m755 $lib $dir + install -m755 /usr/local/lib/$libname $dir copy_deps $lib $dir done } -set +x -copy_deps /usr/local/lib/libmpv.1.dylib public/mpv -copy_deps bindings/build/Release/libtorrent-rasterbar.dylib public/kawabinds -copy_deps bindings/build/Release/libtorrent-rasterbar.10.dylib public/kawabinds -copy_deps bindings/build/Release/libtorrent-rasterbar.1.2.3.dylib public/kawabinds +if [[ $OSTYPE =~ darwin ]] +then + echo "[KawAnime] Collecting dylibs" -copy_deps bindings/build/Release/kawabinds.node public/kawabinds -set -x + set +x + copy_deps /usr/local/lib/libmpv.1.dylib public/mpv + copy_deps bindings/build/Release/libtorrent-rasterbar.10.dylib public + set -x -# See . -install_name_tool -change /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage public/mpv/libavfilter.7.dylib -install_name_tool -change /usr/local/opt/mpv/lib/libmpv.1.dylib '@loader_path/libmpv.1.dylib' ./public/mpv/mpvjs.node + # See . + install_name_tool -change /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage public/mpv/libavfilter.7.dylib + install_name_tool -change /usr/local/opt/mpv/lib/libmpv.1.dylib '@loader_path/libmpv.1.dylib' ./public/mpv/mpvjs.node -# libtorrent-rasterbar.dylib -install_name_tool -change @rpath/libtorrent-rasterbar.10.dylib '@loader_path/libtorrent-rasterbar.10.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/boost/lib/libboost_system.dylib '@loader_path/libboost_system.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/gcc/lib/gcc/9/libstdc++.6.dylib '@loader_path/libstdc++.6.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib - -# libtorrent-rasterbar.10.dylib -install_name_tool -change @rpath/libtorrent-rasterbar.10.dylib '@loader_path/libtorrent-rasterbar.10.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/boost/lib/libboost_system.dylib '@loader_path/libboost_system.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/gcc/lib/gcc/9/libstdc++.6.dylib '@loader_path/libstdc++.6.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib - -# libtorrent-rasterbar.1.2.3.dylib -install_name_tool -change @rpath/libtorrent-rasterbar.10.dylib '@loader_path/libtorrent-rasterbar.10.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/boost/lib/libboost_system.dylib '@loader_path/libboost_system.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib -install_name_tool -change /usr/local/opt/gcc/lib/gcc/9/libstdc++.6.dylib '@loader_path/libstdc++.6.dylib' ./public/kawabinds/libtorrent-rasterbar.dylib - -# kawabinds.node -install_name_tool -change @rpath/kawabinds.node '@loader_path/kawabinds.node' ./public/kawabinds/kawabinds.node -install_name_tool -change @rpath/libtorrent-rasterbar.10.dylib '@loader_path/libtorrent-rasterbar.10.dylib' ./public/kawabinds/kawabinds.node -install_name_tool -change /usr/local/opt/boost/lib/libboost_system.dylib '@loader_path/libstdc++.6.dylib' ./public/kawabinds/kawabinds.node -install_name_tool -change /usr/local/opt/gcc/lib/gcc/9/libstdc++.6.dylib '@loader_path/libboost_system.dylib' ./public/kawabinds/kawabinds.node + install_name_tool -change "@rpath/libtorrent-rasterbar.10.dylib" "@loader_path/libtorrent-rasterbar.10.dylib" bindings/build/Release/kawabinds.node + install_name_tool -change "@rpath/libboost_system.dylib" "@loader_path/libboost_system.dylib" bindings/build/Release/kawabinds.node +fi diff --git a/package.json b/package.json index 305cdcb..d3b1d3a 100644 --- a/package.json +++ b/package.json @@ -14,13 +14,13 @@ "start": "cross-env NODE_ENV=production npm run build:after && electron dist/bundled/background.js", "build": "vue-cli-service electron:build", "build:after": "node scripts/afterBuild.js", - "build:bindings": "cmake-js build -d bindings -O bindings/build && cp -r bindings/build/Release/ public/kawabinds/", + "build:bindings": "cmake-js build -d bindings -O bindings/build && ./collect-dylib-deps.sh", "pack": "npm run build -- --dir", "dist": "npm run dist:mac && npm run dist:win && npm run dist:linux", - "dist:mac": "npm run build -- --mac", - "dist:win": "npm run build -- --win --x64 --ia32", - "dist:portable": "npm run build -- --win portable", - "dist:linux": "npm run build -- --linux deb AppImage", + "dist:mac": "cross-env NODE_ENV=production npm run build -- --mac", + "dist:win": "cross-env NODE_ENV=production npm run build -- --win --x64 --ia32", + "dist:portable": "cross-env NODE_ENV=production npm run build -- --win portable", + "dist:linux": "cross-env NODE_ENV=production npm run build -- --linux deb AppImage", "publish:mac": "npm run build -- --mac -p always", "publish:linux": "npm run build -- --linux deb AppImage -p always", "publish:win": "npm run build -- --win --x64 --ia32 -p always", diff --git a/public/kawabinds/.gitkeep b/public/kawabinds/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/libboost_system.dylib b/public/libboost_system.dylib new file mode 100755 index 0000000..b976a94 Binary files /dev/null and b/public/libboost_system.dylib differ diff --git a/public/libtorrent-rasterbar.10.dylib b/public/libtorrent-rasterbar.10.dylib new file mode 100755 index 0000000..fda5681 Binary files /dev/null and b/public/libtorrent-rasterbar.10.dylib differ diff --git a/vue.config.js b/vue.config.js index 0d5fbcd..5888c4c 100644 --- a/vue.config.js +++ b/vue.config.js @@ -19,7 +19,6 @@ const getAllFiles = (dir) => const VERSION = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'))).version const VENDOR_PATH = path.join(__dirname, 'src', 'vendor') const BIDNINGS_PATH = path.join(__dirname, 'bindings') -const PUBLIC_PATH = path.join(__dirname, 'public') process.env.VUE_APP_KAWANIME_VERSION = VERSION @@ -42,6 +41,11 @@ module.exports = { builderOptions: { appId: 'KawAnime', productName: 'KawAnime', + + // See https://github.com/electron-userland/electron-builder/issues/2738#issuecomment-378837434 + // Not needed anyway + asar: false, + dmg: { contents: [ { @@ -73,33 +77,7 @@ module.exports = { ] }], linux: { - category: 'Network', - extraResources: [ - { - from: './bindings/build/Release', - to: '.', - filter: ['*.so'] - }, - { - from: './public/mpv', - to: 'mpv', - filter: ['*.so', '*.node'] - } - ] - }, - win: { - extraResources: [ - { - from: '.\\bindings\\build\\Release', - to: '.', - filter: ['*.dll'] - }, - { - from: '.\\public\\mpv', - to: 'mpv', - filter: ['*.dll', '*.node'] - } - ] + category: 'Network' } }, chainWebpackMainProcess: (config) => { @@ -117,7 +95,7 @@ module.exports = { .alias .set('vendor', VENDOR_PATH) .set('kawabinds', BIDNINGS_PATH) - .set('public', PUBLIC_PATH) + .set('plugin', process.env.NODE_ENV === 'development' ? path.join(__dirname, 'public') : __dirname) }, chainWebpackRendererProcess: (config) => { // Chain webpack config for electron renderer process only