fix(build): bundle service tools from the resolved IPC source

This commit is contained in:
Tunglies
2026-12-04 15:38:22 +08:00
parent 6f81fb91b3
commit 72c3653a8a
5 changed files with 65 additions and 49 deletions
+20 -17
View File
@@ -9,7 +9,7 @@ import AdmZip from 'adm-zip'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { extract } from 'tar'
import { resolveServiceRelease } from './service-release.mjs'
import { resolveServiceBundle as serviceBundleFromMetadata } from './service-release.mjs'
import { log_debug, log_error, log_info, log_success } from './utils.mjs'
/** Prepares platform resources, caching versions and unchanged files unless `--force` is used. */
@@ -581,23 +581,30 @@ async function resolveServiceBundle() {
}
})
const cargoManifest = await fsp.readFile(
path.join(cwd, 'src-tauri', 'Cargo.toml'),
'utf8',
const metadata = JSON.parse(
execFileSync(
'cargo',
[
'metadata',
'--locked',
'--format-version',
'1',
'--filter-platform',
SIDECAR_HOST,
],
{ cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
),
)
const serviceDependency = cargoManifest
.split(/\r?\n/)
.find((line) => line.trimStart().startsWith('clash_verge_service_ipc ='))
const sourcePath = serviceDependency?.match(/\bpath\s*=\s*"([^"]+)"/)?.[1]
if (sourcePath) {
const manifest = path.resolve(cwd, 'src-tauri', sourcePath, 'Cargo.toml')
const bundle = serviceBundleFromMetadata(metadata, SIDECAR_HOST, platform)
if (bundle.manifest) {
const targetDirectory = path.join(cwd, 'target', 'bundled-service')
execFileSync(
'cargo',
[
'build',
'--locked',
'--manifest-path',
manifest,
bundle.manifest,
'--target-dir',
targetDirectory,
'--target',
@@ -605,7 +612,7 @@ async function resolveServiceBundle() {
'--release',
'--features',
'standalone,client',
'--bins',
...SERVICE_BINARIES.flatMap((name) => ['--bin', name]),
],
{ stdio: 'inherit' },
)
@@ -620,11 +627,7 @@ async function resolveServiceBundle() {
}
return
}
const { archiveFile, downloadURL } = resolveServiceRelease(
cargoManifest,
SIDECAR_HOST,
platform,
)
const { archiveFile, downloadURL } = bundle
const tempDir = path.join(TEMP_DIR, 'clash-verge-service-ipc')
const tempArchive = path.join(tempDir, archiveFile)