* feat: add experimental Apple Silicon support with Nivfold Integrate the standalone Nivfold protocol 1 runner; tested against Nivfold f436fb6. The Windows Reims vGPU runtime remains independent. * fix: open QQ invites and VM SSH on macOS * fix: move VM, View and Help to the macOS menu bar * feat(macos): add resumable Apple restore image downloads Expose the compatible restore image in the VM wizard and Images page, validate downloads before caching, and fix macOS memory reporting and plugin SVG rendering. * fix(macos): localize the native application menu * fix(macos): address native desktop review findings
55 lines
2.6 KiB
JavaScript
55 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
import { execFileSync } from 'node:child_process'
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { cachePath, REPO_ROOT, resolveStorageRoot, runsPath } from './debug/paths.mjs'
|
|
import { createTemporaryFiles } from './debug/temporary-files.mjs'
|
|
|
|
if (process.platform !== 'darwin' || process.arch !== 'arm64') {
|
|
console.error('This build requires an Apple silicon Mac and the Xcode toolchain.')
|
|
process.exit(1)
|
|
}
|
|
|
|
const root = resolveStorageRoot()
|
|
const temps = createTemporaryFiles(root)
|
|
const output = runsPath(root, 'macos-client')
|
|
const goCache = cachePath(root, 'go-build')
|
|
const input = process.argv.slice(2)
|
|
if (input.length !== 0 && (input.length !== 2 || input[0] !== '--runtime')) {
|
|
console.error('Usage: node scripts/build-macos.mjs [--runtime <built-nivfold>]')
|
|
process.exit(1)
|
|
}
|
|
const external = input.length ? path.resolve(input[1]) : null
|
|
const directory = temps.create('build-macos', process.pid)
|
|
const env = { ...process.env, TMPDIR: directory, GOTMPDIR: directory, GOCACHE: goCache, CGO_ENABLED: '1' }
|
|
const run = (command, args) => execFileSync(command, args, { cwd: REPO_ROOT, env, stdio: 'inherit' })
|
|
|
|
function stageRuntime(source) {
|
|
const staged = path.join(directory, 'nivfold')
|
|
fs.copyFileSync(source, staged, fs.constants.COPYFILE_EXCL)
|
|
fs.accessSync(staged, fs.constants.X_OK)
|
|
run('codesign', ['--verify', '--strict', staged])
|
|
const report = JSON.parse(execFileSync(staged, ['probe'], { cwd: REPO_ROOT, env, timeout: 5000, encoding: 'utf8' }))
|
|
if (report.runtime !== 'nivfold' || report.protocol_version !== 1 || report.supported !== true) {
|
|
throw new Error('expected a compatible Nivfold runtime (protocol 1)')
|
|
}
|
|
return staged
|
|
}
|
|
|
|
try {
|
|
for (const dir of [output, goCache]) fs.mkdirSync(dir, { recursive: true })
|
|
const helper = external ? stageRuntime(external) : null
|
|
run('pnpm', ['--dir', 'frontend', '--store-dir', cachePath(root, 'pnpm-store'), 'install', '--frozen-lockfile'])
|
|
run('pnpm', ['--dir', 'frontend', 'run', 'build'])
|
|
const client = path.join(directory, 'reims-go')
|
|
run('go', ['build', '-trimpath', '-tags', 'desktop,production', '-o', client, '.'])
|
|
if (helper) fs.renameSync(helper, path.join(output, 'nivfold'))
|
|
fs.renameSync(client, path.join(output, 'reims-go'))
|
|
temps.close(directory)
|
|
console.log(`Native macOS client: ${path.join(output, 'reims-go')}`)
|
|
if (!helper) console.log('The client build does not install a VM runtime. Pass --runtime with a trusted Nivfold build to install it beside the client.')
|
|
} catch (error) {
|
|
console.error(`macOS build failed: ${error.message}\nBuild directory retained: ${directory}`)
|
|
process.exitCode = 1
|
|
}
|