refactor: deprecate Vulkan external binaries (#6638)

* refactor: deprecate vulkan binary

refactor: clean up vulkan lib

chore: cleanup

chore: clean up

chore: clean up

fix: build

* fix: skip binaries download env

* Update src-tauri/utils/src/system.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src-tauri/utils/src/system.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Louis
2025-09-29 17:47:59 +07:00
committed by GitHub
parent 3c4c6d1c50
commit 5fd249c72d
20 changed files with 249 additions and 318 deletions

View File

@@ -1,4 +1,3 @@
console.log('Script is running')
// scripts/download.js
import https from 'https'
import fs, { copyFile, mkdirSync } from 'fs'
@@ -69,7 +68,10 @@ function getPlatformArch() {
arch === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin'
} else if (platform === 'linux') {
bunPlatform = arch === 'arm64' ? 'linux-aarch64' : 'linux-x64'
uvPlatform = arch === 'arm64' ? 'aarch64-unknown-linux-gnu' : 'x86_64-unknown-linux-gnu'
uvPlatform =
arch === 'arm64'
? 'aarch64-unknown-linux-gnu'
: 'x86_64-unknown-linux-gnu'
} else if (platform === 'win32') {
bunPlatform = 'windows-x64' // Bun has limited Windows support
uvPlatform = 'x86_64-pc-windows-msvc'
@@ -81,6 +83,10 @@ function getPlatformArch() {
}
async function main() {
if (process.env.SKIP_BINARIES) {
console.log('Skipping binaries download.')
process.exit(0)
}
console.log('Starting main function')
const platform = os.platform()
const { bunPlatform, uvPlatform } = getPlatformArch()
@@ -124,29 +130,45 @@ async function main() {
if (err) {
console.log('Add execution permission failed!', err)
}
});
})
if (platform === 'darwin') {
copyFile(path.join(binDir, 'bun'), path.join(binDir, 'bun-x86_64-apple-darwin'), (err) => {
if (err) {
console.log("Error Found:", err);
}
})
copyFile(path.join(binDir, 'bun'), path.join(binDir, 'bun-aarch64-apple-darwin'), (err) => {
if (err) {
console.log("Error Found:", err);
}
})
copyFile(path.join(binDir, 'bun'), path.join(binDir, 'bun-universal-apple-darwin'), (err) => {
copyFile(
path.join(binDir, 'bun'),
path.join(binDir, 'bun-x86_64-apple-darwin'),
(err) => {
if (err) {
console.log("Error Found:", err);
console.log('Error Found:', err)
}
})
} else if (platform === 'linux') {
copyFile(path.join(binDir, 'bun'), path.join(binDir, 'bun-x86_64-unknown-linux-gnu'), (err) => {
if (err) {
console.log("Error Found:", err);
}
})
)
copyFile(
path.join(binDir, 'bun'),
path.join(binDir, 'bun-aarch64-apple-darwin'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
)
copyFile(
path.join(binDir, 'bun'),
path.join(binDir, 'bun-universal-apple-darwin'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
)
} else if (platform === 'linux') {
copyFile(
path.join(binDir, 'bun'),
path.join(binDir, 'bun-x86_64-unknown-linux-gnu'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
)
}
} catch (err) {
// Expect EEXIST error
@@ -157,11 +179,15 @@ async function main() {
path.join(binDir)
)
if (platform === 'win32') {
copyFile(path.join(binDir, 'bun.exe'), path.join(binDir, 'bun-x86_64-pc-windows-msvc.exe'), (err) => {
if (err) {
console.log("Error Found:", err);
copyFile(
path.join(binDir, 'bun.exe'),
path.join(binDir, 'bun-x86_64-pc-windows-msvc.exe'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
)
}
} catch (err) {
// Expect EEXIST error
@@ -176,52 +202,66 @@ async function main() {
await decompress(uvPath, tempBinDir)
}
try {
copySync(
path.join(tempBinDir, `uv-${uvPlatform}`, 'uv'),
path.join(binDir)
)
copySync(path.join(tempBinDir, `uv-${uvPlatform}`, 'uv'), path.join(binDir))
fs.chmod(path.join(binDir, 'uv'), 0o755, (err) => {
if (err) {
console.log('Add execution permission failed!', err)
}
});
})
if (platform === 'darwin') {
copyFile(path.join(binDir, 'uv'), path.join(binDir, 'uv-x86_64-apple-darwin'), (err) => {
if (err) {
console.log("Error Found:", err);
copyFile(
path.join(binDir, 'uv'),
path.join(binDir, 'uv-x86_64-apple-darwin'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
copyFile(path.join(binDir, 'uv'), path.join(binDir, 'uv-aarch64-apple-darwin'), (err) => {
if (err) {
console.log("Error Found:", err);
)
copyFile(
path.join(binDir, 'uv'),
path.join(binDir, 'uv-aarch64-apple-darwin'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
copyFile(path.join(binDir, 'uv'), path.join(binDir, 'uv-universal-apple-darwin'), (err) => {
if (err) {
console.log("Error Found:", err);
)
copyFile(
path.join(binDir, 'uv'),
path.join(binDir, 'uv-universal-apple-darwin'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
)
} else if (platform === 'linux') {
copyFile(path.join(binDir, 'uv'), path.join(binDir, 'uv-x86_64-unknown-linux-gnu'), (err) => {
if (err) {
console.log("Error Found:", err);
copyFile(
path.join(binDir, 'uv'),
path.join(binDir, 'uv-x86_64-unknown-linux-gnu'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
)
}
} catch (err) {
// Expect EEXIST error
}
try {
copySync(
path.join(tempBinDir, 'uv.exe'),
path.join(binDir)
)
copySync(path.join(tempBinDir, 'uv.exe'), path.join(binDir))
if (platform === 'win32') {
copyFile(path.join(binDir, 'uv.exe'), path.join(binDir, 'uv-x86_64-pc-windows-msvc.exe'), (err) => {
if (err) {
console.log("Error Found:", err);
copyFile(
path.join(binDir, 'uv.exe'),
path.join(binDir, 'uv-x86_64-pc-windows-msvc.exe'),
(err) => {
if (err) {
console.log('Error Found:', err)
}
}
})
)
}
} catch (err) {
// Expect EEXIST error

View File

@@ -1,86 +0,0 @@
console.log('Script is running')
// scripts/download-lib.mjs
import https from 'https'
import fs, { mkdirSync } from 'fs'
import os from 'os'
import path from 'path'
import { copySync } from 'cpx'
function download(url, dest) {
return new Promise((resolve, reject) => {
console.log(`Downloading ${url} to ${dest}`)
const file = fs.createWriteStream(dest)
https
.get(url, (response) => {
console.log(`Response status code: ${response.statusCode}`)
if (
response.statusCode >= 300 &&
response.statusCode < 400 &&
response.headers.location
) {
// Handle redirect
const redirectURL = response.headers.location
console.log(`Redirecting to ${redirectURL}`)
download(redirectURL, dest).then(resolve, reject) // Recursive call
return
} else if (response.statusCode !== 200) {
reject(`Failed to get '${url}' (${response.statusCode})`)
return
}
response.pipe(file)
file.on('finish', () => {
file.close(resolve)
})
})
.on('error', (err) => {
fs.unlink(dest, () => reject(err.message))
})
})
}
async function main() {
console.log('Starting main function')
const platform = os.platform() // 'darwin', 'linux', 'win32'
const arch = os.arch() // 'x64', 'arm64', etc.
if (arch != 'x64') return
let filename
if (platform == 'linux')
filename = 'libvulkan.so'
else if (platform == 'win32')
filename = 'vulkan-1.dll'
else
return
const url = `https://catalog.jan.ai/${filename}`
const libDir = 'src-tauri/resources/lib'
const tempDir = 'scripts/dist'
try {
mkdirSync('scripts/dist')
} catch (err) {
// Expect EEXIST error if the directory already exists
}
console.log(`Downloading libvulkan...`)
const savePath = path.join(tempDir, filename)
if (!fs.existsSync(savePath)) {
await download(url, savePath)
}
// copy to tauri resources
try {
copySync(savePath, libDir)
} catch (err) {
// Expect EEXIST error
}
console.log('Downloads completed.')
}
main().catch((err) => {
console.error('Error:', err)
process.exit(1)
})