Files
DOSSIER/scripts/cycles/tauri-prepare.mjs
T
Claude 50c8aec2ba
check / check (push) Has been cancelled
check / licenses (push) Has been cancelled
check / e2e (push) Has been cancelled
macos / native (push) Has been cancelled
cycles / linux (push) Has been cancelled
cycles / macos (push) Has been cancelled
[215] Mac-Bau: symbolische Links im Cycles-Paket vor dem Tauri-Bündeln auflösen (Not a directory)
2026-11-18 23:05:03 +00:00

46 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
// [215] Tauri (macOS): ausgepacktes Cycles-Paket (build/cycles, scripts/cycles/get.sh) als Sidecar bereitstellen.
// node scripts/cycles/tauri-prepare.mjs [Paketordner] (Standard: build/cycles)
// `bundle.externalBin: ["binaries/cycles"]` (src-tauri/tauri.cycles.conf.json) verlangt je Ziel `binaries/cycles-<triple>`.
// Das Paket ist arm64: für die universale App (arm64 + x64) entstehen auch die Namen x86_64 und universal — Kopien des
// arm64-Programms, nur damit der Bau durchläuft; auf Intel-Macs meldet `cycles_where` (src-tauri/src/cycles.rs) „nicht verfügbar“.
// `scripts/tauri-native.mjs` hängt die Konfiguration automatisch an `tauri build`, sobald die Sidecars da sind.
import { copyFileSync, existsSync, mkdirSync, chmodSync } from "node:fs";
import { join, resolve } from "node:path";
const root = resolve(import.meta.dirname, "..", "..");
const dir = resolve(process.argv[2] ?? join(root, "build", "cycles"));
const bin = join(dir, "cycles");
if (!existsSync(bin)) {
console.error(`tauri-prepare: ${bin} fehlt — zuerst scripts/cycles/get.sh macos arm64`);
process.exit(1);
}
const out = join(root, "src-tauri", "binaries");
mkdirSync(out, { recursive: true });
for (const triple of ["aarch64-apple-darwin", "x86_64-apple-darwin", "universal-apple-darwin"]) {
const to = join(out, `cycles-${triple}`);
copyFileSync(bin, to);
chmodSync(to, 0o755);
console.log(`tauri-prepare: ${to}`);
}
// Tauri kopiert `bundle.resources` Datei für Datei und bricht an symbolischen Links ab („Not a directory“, z. B.
// lib/libopenjph.dylib → libopenjph.0.x.dylib im macOS-Paket). Links in lib/ durch echte Kopien ersetzen.
import { lstatSync, readdirSync, readlinkSync, rmSync, statSync } from "node:fs";
import { dirname } from "node:path";
function derefLinks(d) {
if (!existsSync(d)) return;
for (const name of readdirSync(d)) {
const p = join(d, name);
const st = lstatSync(p);
if (st.isSymbolicLink()) {
const target = resolve(dirname(p), readlinkSync(p));
if (!existsSync(target) || !statSync(target).isFile()) { rmSync(p); console.log(`tauri-prepare: Link entfernt ${p}`); continue; }
rmSync(p);
copyFileSync(target, p);
console.log(`tauri-prepare: Link aufgelöst ${p}`);
} else if (st.isDirectory()) derefLinks(p);
}
}
for (const sub of ["lib", "source", "licenses"]) derefLinks(join(dir, sub));