mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/lyswhut/lx-music-desktop.git
synced 2026-09-20 08:04:00 +08:00
fix: 修复架构映射以正确复制库文件
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// const fs = require('fs')
|
// const fs = require('fs')
|
||||||
// const fsPromises = require('fs').promises
|
// const fsPromises = require('fs').promises
|
||||||
// const path = require('path')
|
// const path = require('path')
|
||||||
// const { Arch } = require('electron-builder')
|
const { Arch } = require('electron-builder')
|
||||||
// const nodeAbi = require('node-abi')
|
// const nodeAbi = require('node-abi')
|
||||||
const { beforePack, copyLib } = require('./deps')
|
const { beforePack, copyLib } = require('./deps')
|
||||||
|
|
||||||
@@ -24,12 +24,17 @@ const { beforePack, copyLib } = require('./deps')
|
|||||||
// await fsPromises.copyFile(filePath, targetPath)
|
// await fsPromises.copyFile(filePath, targetPath)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
const archMap = {
|
||||||
|
[Arch.x64]: 'x64',
|
||||||
|
[Arch.ia32]: 'ia32',
|
||||||
|
[Arch.arm64]: 'arm64',
|
||||||
|
[Arch.armv7l]: 'armv7l',
|
||||||
|
}
|
||||||
module.exports = async(context) => {
|
module.exports = async(context) => {
|
||||||
await beforePack()
|
await beforePack()
|
||||||
const { arch } = context
|
const { arch } = context
|
||||||
await copyLib(arch)
|
const electronVersion = context.packager?.info?._framework?.version ?? require('../package.json').devDependencies.electron.replace(/^[^\d]*?(\d+)/, '$1')
|
||||||
// const electronVersion = context.packager?.info?._framework?.version ?? require('../package.json').devDependencies.electron.replace(/^[^\d]*?(\d+)/, '$1')
|
await copyLib(archMap[arch], parseInt(electronVersion) == 22)
|
||||||
// const electronNodeAbi = nodeAbi.getAbi(electronVersion, 'electron')
|
// const electronNodeAbi = nodeAbi.getAbi(electronVersion, 'electron')
|
||||||
// if (electronPlatformName !== 'linux' || process.env.FORCE) return
|
// if (electronPlatformName !== 'linux' || process.env.FORCE) return
|
||||||
// // const bindingFilePath = path.join(__dirname, '../node_modules/better-sqlite3/binding.gyp')
|
// // const bindingFilePath = path.join(__dirname, '../node_modules/better-sqlite3/binding.gyp')
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ const replaceSqliteLib = async(arch) => {
|
|||||||
await fs.promises.unlink(targetPath).catch(_ => _)
|
await fs.promises.unlink(targetPath).catch(_ => _)
|
||||||
await fs.promises.copyFile(filePath, targetPath)
|
await fs.promises.copyFile(filePath, targetPath)
|
||||||
}
|
}
|
||||||
exports.copyLib = async(arch = process.arch) => {
|
exports.copyLib = async(arch = process.arch, replaceLocal = false) => {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux' || replaceLocal) {
|
||||||
await replaceSqliteLib(arch)
|
await replaceSqliteLib(arch)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const files = ['better_sqlite3']
|
|||||||
const moveFile = async(filePath) => {
|
const moveFile = async(filePath) => {
|
||||||
const name = `${path.basename(filePath).split('_v')[0].replace('_', '-')}`
|
const name = `${path.basename(filePath).split('_v')[0].replace('_', '-')}`
|
||||||
for (const fileName of files) {
|
for (const fileName of files) {
|
||||||
if (fileName == 'better_sqlite3' && !name.includes('linux')) continue
|
// if (fileName == 'better_sqlite3' && !name.includes('linux')) continue
|
||||||
const targetPath = path.join(libDir, `${fileName}_${name}.node`)
|
const targetPath = path.join(libDir, `${fileName}_${name}.node`)
|
||||||
if (fs.existsSync(targetPath)) await fs.promises.unlink(targetPath)
|
if (fs.existsSync(targetPath)) await fs.promises.unlink(targetPath)
|
||||||
await fs.promises.rename(path.join(filePath, `${fileName}.node`), targetPath)
|
await fs.promises.rename(path.join(filePath, `${fileName}.node`), targetPath)
|
||||||
|
|||||||
BIN
build-config/lib/better_sqlite3_win32-ia32.node
Normal file
BIN
build-config/lib/better_sqlite3_win32-ia32.node
Normal file
Binary file not shown.
BIN
build-config/lib/better_sqlite3_win32-x64.node
Normal file
BIN
build-config/lib/better_sqlite3_win32-x64.node
Normal file
Binary file not shown.
Reference in New Issue
Block a user