Skip to content

Commit 80053ee

Browse files
author
kun.ran
committed
feat: support mac x64
1 parent e2380cf commit 80053ee

8 files changed

Lines changed: 83 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
132132

133133
if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64")
134134
set(QD_CPU_ARCH arm64)
135+
elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
136+
set(QD_CPU_ARCH x64)
135137
endif()
136138
endif()
137139

QuickDesk/src/controller/MainController.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ QString MainController::getSkillHostBinaryPath() const {
12151215
QString MainController::getBuiltinSkillsDir() const {
12161216
auto appDir = QCoreApplication::applicationDirPath();
12171217
#if defined(Q_OS_MAC)
1218-
// Dev tree first (output/arm64/<mode>/skills, next to the dev-built
1218+
// Dev tree first (output/<arch>/<mode>/skills, next to the dev-built
12191219
// quickdesk-skill-host binary). Falls back to the packaged location
12201220
// under Contents/Resources/skills for the .app bundle.
12211221
QString devSkills = appDir + "/../../../skills";

QuickDesk/src/controller/MainController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private slots:
286286
// Locate the directory that holds built-in skills (sys-info, file-ops, ...).
287287
// Layout differs by platform / build mode:
288288
// - macOS bundle: <App>.app/Contents/Resources/skills
289-
// - macOS dev tree: output/arm64/<mode>/skills (next to the binary)
289+
// - macOS dev tree: output/<arch>/<mode>/skills (next to the binary)
290290
// - Windows/Linux: <executable dir>/skills
291291
QString getBuiltinSkillsDir() const;
292292
void setupWebSocketApiEvents();

QuickDesk/src/manager/ProcessManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,14 @@ QString ProcessManager::findExecutable(const QString& name)
651651
#endif
652652

653653
#ifdef QT_DEBUG
654+
#if defined(__x86_64__) && defined(Q_OS_MAC)
655+
searchPaths << QDir(appDir).filePath(kRelPrefix + "Debug-x64");
656+
#endif
654657
searchPaths << QDir(appDir).filePath(kRelPrefix + "Debug");
655658
#else
659+
#if defined(__x86_64__) && defined(Q_OS_MAC)
660+
searchPaths << QDir(appDir).filePath(kRelPrefix + "Release-x64");
661+
#endif
656662
searchPaths << QDir(appDir).filePath(kRelPrefix + "Release");
657663
#endif
658664

@@ -666,7 +672,11 @@ QString ProcessManager::findExecutable(const QString& name)
666672

667673
#ifdef Q_OS_MAC
668674
// 3rdparty directory (for development)
675+
#if defined(__x86_64__)
676+
searchPaths << QDir(appDir).filePath("../../../QuickDesk/3rdparty/quickdesk-remoting/x64");
677+
#else
669678
searchPaths << QDir(appDir).filePath("../../../QuickDesk/3rdparty/quickdesk-remoting/arm64");
679+
#endif
670680
// Contents/Frameworks/ for .app bundles (publish layout)
671681
searchPaths << QDir(appDir).filePath("../Frameworks");
672682
#endif

scripts/build_mcp_mac.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ old_cd=$(pwd)
1616
cd "$(dirname "$0")"
1717

1818
build_mode=release
19+
arch=arm64
1920

2021
echo
2122
echo
@@ -27,15 +28,18 @@ while [ $# -gt 0 ]; do
2728
case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in
2829
debug) build_mode=debug ;;
2930
release) build_mode=release ;;
31+
arm64|arm) arch=arm64 ;;
32+
x64|x86_64|intel) arch=x64 ;;
3033
esac
3134
shift
3235
done
3336

3437
echo "[*] build mode: $build_mode"
38+
echo "[*] target arch: $arch"
3539
echo
3640

3741
mcp_dir="$script_path/../quickdesk-mcp"
38-
output_path="$script_path/../output/arm64"
42+
output_path="$script_path/../output/$arch"
3943

4044
echo "[*] mcp dir: $mcp_dir"
4145
echo "[*] output path: $output_path"
@@ -49,23 +53,31 @@ fi
4953
cd "$mcp_dir"
5054
echo "[*] building quickdesk-mcp..."
5155

56+
# Determine Rust target for cross-compilation
57+
rust_target_flag=""
58+
rust_target_dir=""
59+
if [ "$arch" = "x64" ]; then
60+
rust_target_flag="--target x86_64-apple-darwin"
61+
rust_target_dir="x86_64-apple-darwin/"
62+
fi
63+
5264
if [ "$build_mode" = "debug" ]; then
53-
cargo build
65+
cargo build $rust_target_flag
5466
if [ $? -ne 0 ]; then
5567
echo "[!] cargo build failed"
5668
cd "$old_cd"
5769
exit 1
5870
fi
59-
cargo_out="$mcp_dir/target/debug"
71+
cargo_out="$mcp_dir/target/${rust_target_dir}debug"
6072
dest_dir="$output_path/Debug"
6173
else
62-
cargo build --release
74+
cargo build --release $rust_target_flag
6375
if [ $? -ne 0 ]; then
6476
echo "[!] cargo build failed"
6577
cd "$old_cd"
6678
exit 1
6779
fi
68-
cargo_out="$mcp_dir/target/release"
80+
cargo_out="$mcp_dir/target/${rust_target_dir}release"
6981
dest_dir="$output_path/Release"
7082
fi
7183

scripts/build_qd_mac.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ cd "$(dirname "$0")"
2222

2323
build_mode=Release
2424
clean_output=false
25+
arch=arm64
2526
errno=1
2627

2728
echo
@@ -37,13 +38,15 @@ while [ $# -gt 0 ]; do
3738
minsizerel) build_mode=MinSizeRel ;;
3839
relwithdebinfo) build_mode=RelWithDebInfo ;;
3940
clean) clean_output=true ;;
41+
arm64|arm) arch=arm64 ;;
42+
x64|x86_64|intel) arch=x64 ;;
4043
esac
4144
shift
4245
done
4346

4447
echo "[*] build mode: $build_mode"
4548
echo "[*] clean output: $clean_output"
46-
echo
49+
echo "[*] target arch: $arch"
4750

4851
qt_cmake_path="$ENV_QT_PATH/macos"
4952
echo "Qt cmake path: $qt_cmake_path"
@@ -79,7 +82,13 @@ if [ ! -d "$temp_path" ]; then
7982
fi
8083
cd "$temp_path"
8184

82-
cmake_params="-DCMAKE_PREFIX_PATH=$qt_cmake_path -DCMAKE_BUILD_TYPE=$build_mode -DCMAKE_OSX_ARCHITECTURES=arm64"
85+
if [ "$arch" = "x64" ]; then
86+
cmake_osx_arch="x86_64"
87+
else
88+
cmake_osx_arch="$arch"
89+
fi
90+
91+
cmake_params="-DCMAKE_PREFIX_PATH=$qt_cmake_path -DCMAKE_BUILD_TYPE=$build_mode -DCMAKE_OSX_ARCHITECTURES=$cmake_osx_arch"
8392

8493
if [ -n "$ENV_QUICKDESK_API_KEY" ]; then
8594
cmake_params="$cmake_params -DQUICKDESK_API_KEY=$ENV_QUICKDESK_API_KEY"

scripts/build_skill_host_mac.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ old_cd=$(pwd)
1616
cd "$(dirname "$0")"
1717

1818
build_mode=release
19+
arch=arm64
1920

2021
echo
2122
echo
@@ -27,15 +28,18 @@ while [ $# -gt 0 ]; do
2728
case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in
2829
debug) build_mode=debug ;;
2930
release) build_mode=release ;;
31+
arm64|arm) arch=arm64 ;;
32+
x64|x86_64|intel) arch=x64 ;;
3033
esac
3134
shift
3235
done
3336

3437
echo "[*] build mode: $build_mode"
38+
echo "[*] target arch: $arch"
3539
echo
3640

3741
skill_host_dir="$script_path/../quickdesk-skill-host"
38-
output_path="$script_path/../output/arm64"
42+
output_path="$script_path/../output/$arch"
3943

4044
echo "[*] skill-host workspace dir: $skill_host_dir"
4145
echo "[*] output path: $output_path"
@@ -49,23 +53,31 @@ fi
4953
cd "$skill_host_dir"
5054
echo "[*] building quickdesk-skill-host workspace..."
5155

56+
# Determine Rust target for cross-compilation
57+
rust_target_flag=""
58+
rust_target_dir=""
59+
if [ "$arch" = "x64" ]; then
60+
rust_target_flag="--target x86_64-apple-darwin"
61+
rust_target_dir="x86_64-apple-darwin/"
62+
fi
63+
5264
if [ "$build_mode" = "debug" ]; then
53-
cargo build
65+
cargo build $rust_target_flag
5466
if [ $? -ne 0 ]; then
5567
echo "[!] cargo build failed"
5668
cd "$old_cd"
5769
exit 1
5870
fi
59-
cargo_out="$skill_host_dir/target/debug"
71+
cargo_out="$skill_host_dir/target/${rust_target_dir}debug"
6072
dest_dir="$output_path/Debug"
6173
else
62-
cargo build --release
74+
cargo build --release $rust_target_flag
6375
if [ $? -ne 0 ]; then
6476
echo "[!] cargo build failed"
6577
cd "$old_cd"
6678
exit 1
6779
fi
68-
cargo_out="$skill_host_dir/target/release"
80+
cargo_out="$skill_host_dir/target/${rust_target_dir}release"
6981
dest_dir="$output_path/Release"
7082
fi
7183

scripts/publish_qd_mac.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ old_cd=$(pwd)
2121
cd "$(dirname "$0")"
2222

2323
build_mode=Release
24+
arch=arm64
2425
errno=1
2526

2627
echo
@@ -33,18 +34,24 @@ while [ $# -gt 0 ]; do
3334
case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in
3435
debug) build_mode=Debug ;;
3536
release) build_mode=Release ;;
37+
arm64|arm) arch=arm64 ;;
38+
x64|x86_64|intel) arch=x64 ;;
3639
esac
3740
shift
3841
done
3942

40-
echo "[*] arch: arm64"
43+
echo "[*] arch: $arch"
4144
echo "[*] build mode: $build_mode"
4245
echo
4346

4447
qt_mac_path="$ENV_QT_PATH/macos"
4548
publish_path="$script_path/../publish/$build_mode"
46-
release_path="$script_path/../output/arm64/$build_mode"
47-
src_out_path="$script_path/../../src/out/$build_mode"
49+
release_path="$script_path/../output/$arch/$build_mode"
50+
if [ "$arch" = "x64" ]; then
51+
src_out_path="$script_path/../../src/out/$build_mode-x64"
52+
else
53+
src_out_path="$script_path/../../src/out/$build_mode"
54+
fi
4855

4956
echo "[*] Qt macOS path: $qt_mac_path"
5057
echo "[*] publish path: $publish_path"
@@ -84,7 +91,7 @@ resources_dir="$publish_path/QuickDesk.app/Contents/Resources"
8491
mkdir -p "$resources_dir"
8592

8693
echo "[*] copying host and client..."
87-
thirdparty_path="$script_path/../QuickDesk/3rdparty/quickdesk-remoting/arm64"
94+
thirdparty_path="$script_path/../QuickDesk/3rdparty/quickdesk-remoting/$arch"
8895
echo "[*] 3rdparty path: $thirdparty_path"
8996
mkdir -p "$frameworks_dir"
9097

@@ -110,7 +117,7 @@ fi
110117

111118
# Copy MCP bridge
112119
echo "[*] copying quickdesk-mcp..."
113-
mcp_output="$script_path/../output/arm64/$build_mode/quickdesk-mcp"
120+
mcp_output="$script_path/../output/$arch/$build_mode/quickdesk-mcp"
114121
if [ -f "$mcp_output" ]; then
115122
cp "$mcp_output" "$frameworks_dir/"
116123
echo "[*] copied quickdesk-mcp from output"
@@ -121,7 +128,7 @@ echo
121128

122129
# Copy skill-host and built-in skills
123130
echo "[*] copying quickdesk-skill-host..."
124-
skill_host_output="$script_path/../output/arm64/$build_mode/quickdesk-skill-host"
131+
skill_host_output="$script_path/../output/$arch/$build_mode/quickdesk-skill-host"
125132
if [ -f "$skill_host_output" ]; then
126133
cp "$skill_host_output" "$frameworks_dir/"
127134
echo "[*] copied quickdesk-skill-host from output"
@@ -137,7 +144,7 @@ echo "[*] copying built-in skills..."
137144
# must be present") and triggers the "app is damaged" Gatekeeper error.
138145
# Place it under Contents/Resources/ instead, which is the documented
139146
# location for arbitrary application resources.
140-
skills_output="$script_path/../output/arm64/$build_mode/skills"
147+
skills_output="$script_path/../output/$arch/$build_mode/skills"
141148
if [ -d "$skills_output" ]; then
142149
mkdir -p "$resources_dir/skills"
143150
cp -R "$skills_output/"* "$resources_dir/skills/"
@@ -155,6 +162,16 @@ if [ $? -ne 0 ]; then
155162
exit 1
156163
fi
157164

165+
# Fix dylib dependencies that reference build-machine-only paths
166+
rapidocr_dylib="$publish_path/QuickDesk.app/Contents/Frameworks/libRapidOcrOnnx.dylib"
167+
if [ -f "$rapidocr_dylib" ]; then
168+
bad_dep=$(otool -L "$rapidocr_dylib" | grep "/usr/local/opt/llvm" | awk '{print $1}')
169+
if [ -n "$bad_dep" ]; then
170+
echo "[*] fixing libRapidOcrOnnx.dylib: removing build-machine dep ($bad_dep)"
171+
install_name_tool -change "$bad_dep" "/usr/lib/libSystem.B.dylib" "$rapidocr_dylib"
172+
fi
173+
fi
174+
158175
echo "[*] cleaning unnecessary Qt dependencies..."
159176

160177
plugins_dir="$publish_path/QuickDesk.app/Contents/PlugIns"

0 commit comments

Comments
 (0)