mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 09:19:56 -05:00
Fix: MacOS Directory Build Change
This commit is contained in:
@@ -1,24 +1,31 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Moku — Suwayomi launcher sidecar for macOS.
|
# Moku — Suwayomi launcher sidecar for macOS.
|
||||||
# Tauri calls this script directly; the rootDir JVM flag is prepended by
|
# Tauri calls this script directly as a sidecar (Contents/MacOS/suwayomi-server-{arch}).
|
||||||
# spawn_server in lib.rs as the first element of invocation.args.
|
# The Suwayomi bundle is placed by Tauri into Contents/Resources/suwayomi-bundle/.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
# Resolve the real directory of this script, following symlinks.
|
||||||
|
SELF="$0"
|
||||||
|
while [ -L "$SELF" ]; do
|
||||||
|
SELF="$(readlink "$SELF")"
|
||||||
|
done
|
||||||
|
DIR="$(cd "$(dirname "$SELF")" && pwd)"
|
||||||
|
|
||||||
# When running from inside the .app bundle the sidecar lives in
|
# ── Locate the bundle ─────────────────────────────────────────────────────────
|
||||||
# Contents/MacOS/; the bundle is in Contents/Resources/.
|
# Inside .app: sidecar = Contents/MacOS/suwayomi-server-{arch}
|
||||||
# Walk up to find the bundle directory.
|
# bundle = Contents/Resources/suwayomi-bundle/
|
||||||
|
# Dev / flat layout: bundle sits next to the sidecar, or one level up.
|
||||||
find_bundle() {
|
find_bundle() {
|
||||||
local base="$1"
|
local base="$1"
|
||||||
for candidate in \
|
for candidate in \
|
||||||
"${base}/suwayomi-bundle" \
|
|
||||||
"${base}/../Resources/suwayomi-bundle" \
|
"${base}/../Resources/suwayomi-bundle" \
|
||||||
"${base}/../Resources/binaries/suwayomi-bundle" \
|
"${base}/suwayomi-bundle" \
|
||||||
"${base}/../Resources"
|
"${base}/../suwayomi-bundle"
|
||||||
do
|
do
|
||||||
if [ -f "${candidate}/Suwayomi-Server.jar" ]; then
|
# The jar lives at <bundle>/bin/Suwayomi-Server.jar
|
||||||
echo "$candidate"
|
if [ -f "${candidate}/bin/Suwayomi-Server.jar" ]; then
|
||||||
|
# Canonicalise (no readlink -f on older macOS sh, use cd trick)
|
||||||
|
echo "$(cd "$candidate" && pwd)"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -27,14 +34,22 @@ find_bundle() {
|
|||||||
|
|
||||||
BUNDLE=$(find_bundle "$DIR") || {
|
BUNDLE=$(find_bundle "$DIR") || {
|
||||||
echo "[sidecar] ERROR: cannot locate suwayomi-bundle relative to $DIR" >&2
|
echo "[sidecar] ERROR: cannot locate suwayomi-bundle relative to $DIR" >&2
|
||||||
|
echo "[sidecar] Tried:" >&2
|
||||||
|
echo " $DIR/../Resources/suwayomi-bundle" >&2
|
||||||
|
echo " $DIR/suwayomi-bundle" >&2
|
||||||
|
echo " $DIR/../suwayomi-bundle" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
JAVA="${BUNDLE}/jre/bin/java"
|
JAVA="${BUNDLE}/jre/bin/java"
|
||||||
JAR="${BUNDLE}/Suwayomi-Server.jar"
|
JAR="${BUNDLE}/bin/Suwayomi-Server.jar"
|
||||||
|
|
||||||
|
echo "[sidecar] BUNDLE=$BUNDLE" >&2
|
||||||
|
echo "[sidecar] JAVA=$JAVA" >&2
|
||||||
|
echo "[sidecar] JAR=$JAR" >&2
|
||||||
|
|
||||||
if [ ! -x "$JAVA" ]; then
|
if [ ! -x "$JAVA" ]; then
|
||||||
echo "[sidecar] ERROR: java not found at $JAVA" >&2
|
echo "[sidecar] ERROR: java not executable at $JAVA" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$JAR" ]; then
|
if [ ! -f "$JAR" ]; then
|
||||||
@@ -42,6 +57,9 @@ if [ ! -f "$JAR" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# "$@" will contain the -Dsuwayomi.tachidesk.config.server.rootDir=... flag
|
||||||
|
# prepended by spawn_server in lib.rs, followed by -jar <path>.
|
||||||
|
# We call java directly so all JVM flags reach it properly.
|
||||||
exec "$JAVA" \
|
exec "$JAVA" \
|
||||||
-Djava.awt.headless=true \
|
-Djava.awt.headless=true \
|
||||||
"$@" \
|
"$@" \
|
||||||
|
|||||||
+29
-11
@@ -309,21 +309,39 @@ fn resolve_server_binary(
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
|
// Tauri places externalBin sidecars next to the main binary in
|
||||||
|
// Contents/MacOS/, not in Contents/Resources/. Derive that path
|
||||||
|
// from resource_dir (Contents/Resources → Contents/MacOS).
|
||||||
|
let macos_dir = resource_dir.join("../MacOS")
|
||||||
|
.canonicalize()
|
||||||
|
.unwrap_or_else(|_| resource_dir.join("../MacOS"));
|
||||||
|
|
||||||
|
do_log(log, &format!("[resolve] macOS macos_dir = {:?}", macos_dir));
|
||||||
|
|
||||||
|
// Tauri strips the target triple when installing externalBin sidecars
|
||||||
|
// into Contents/MacOS/, so the binary is always just "suwayomi-server"
|
||||||
|
// at runtime. The triple-suffixed names are only needed on disk at
|
||||||
|
// build time for Tauri to pick the right arch during bundling.
|
||||||
let candidates = [
|
let candidates = [
|
||||||
|
"suwayomi-server",
|
||||||
"suwayomi-server-aarch64-apple-darwin",
|
"suwayomi-server-aarch64-apple-darwin",
|
||||||
"suwayomi-server-x86_64-apple-darwin",
|
"suwayomi-server-x86_64-apple-darwin",
|
||||||
"suwayomi-server",
|
|
||||||
];
|
];
|
||||||
for name in &candidates {
|
|
||||||
let p = resource_dir.join(name);
|
// Search MacOS/ first (correct location), then Resources/ as fallback
|
||||||
do_log(log, &format!("[resolve] macOS candidate: {:?} exists={}", p, p.exists()));
|
// for flat dev layouts where the script sits next to resources.
|
||||||
if p.exists() {
|
for search_dir in &[&macos_dir, &resource_dir] {
|
||||||
do_log(log, &format!("[resolve] using macOS candidate: {:?}", p));
|
for name in &candidates {
|
||||||
return Ok(ServerInvocation {
|
let p = search_dir.join(name);
|
||||||
bin: p.to_string_lossy().into_owned(),
|
do_log(log, &format!("[resolve] macOS candidate: {:?} exists={}", p, p.exists()));
|
||||||
args: vec![],
|
if p.exists() {
|
||||||
working_dir: None,
|
do_log(log, &format!("[resolve] using macOS sidecar: {:?}", p));
|
||||||
});
|
return Ok(ServerInvocation {
|
||||||
|
bin: p.to_string_lossy().into_owned(),
|
||||||
|
args: vec![],
|
||||||
|
working_dir: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user