fix: resolve macOS build issue by disabling cross tool for apple-darwin targets (#200)

This commit is contained in:
安正超
2025-07-14 19:25:01 +08:00
committed by GitHub
parent 36e3efb5a5
commit b9bbae27de
+17 -1
View File
@@ -289,8 +289,15 @@ build_binary() {
local current_platform=$(detect_platform) local current_platform=$(detect_platform)
# Check if we need cross-compilation # Check if we need cross-compilation
# Note: macOS targets (darwin) cannot use cross tool as it requires Docker
if [ "$PLATFORM" != "$current_platform" ]; then if [ "$PLATFORM" != "$current_platform" ]; then
# Check if cross is available # Check if the target is a macOS target
if [[ "$PLATFORM" == *"apple-darwin"* ]]; then
print_message $YELLOW "🍎 macOS target detected, using native cargo build"
print_message $YELLOW "💡 Note: macOS targets must be built natively on macOS runners"
build_cmd="cargo build"
else
# Check if cross is available for non-macOS targets
if command -v cross &> /dev/null; then if command -v cross &> /dev/null; then
build_cmd="cross build" build_cmd="cross build"
print_message $YELLOW "🔄 Cross-compilation detected, using 'cross' tool" print_message $YELLOW "🔄 Cross-compilation detected, using 'cross' tool"
@@ -301,6 +308,7 @@ build_binary() {
build_cmd="cross build" build_cmd="cross build"
fi fi
fi fi
fi
if [ "$BUILD_TYPE" = "release" ]; then if [ "$BUILD_TYPE" = "release" ]; then
build_cmd+=" --release" build_cmd+=" --release"
@@ -347,12 +355,20 @@ build_binary() {
# Provide helpful suggestions for cross-compilation failures # Provide helpful suggestions for cross-compilation failures
if [ "$PLATFORM" != "$(detect_platform)" ]; then if [ "$PLATFORM" != "$(detect_platform)" ]; then
if [[ "$PLATFORM" == *"apple-darwin"* ]]; then
print_message $YELLOW "💡 macOS build suggestions:"
print_message $YELLOW " 1. macOS targets must be built natively on macOS systems"
print_message $YELLOW " 2. Use GitHub Actions with macos-latest runner"
print_message $YELLOW " 3. Ensure Xcode command line tools are installed"
print_message $YELLOW " 4. Try: rustup target add $PLATFORM"
else
print_message $YELLOW "💡 Cross-compilation suggestions:" print_message $YELLOW "💡 Cross-compilation suggestions:"
print_message $YELLOW " 1. Use Docker build: make build-docker" print_message $YELLOW " 1. Use Docker build: make build-docker"
print_message $YELLOW " 2. Use GitHub Actions for multi-platform builds" print_message $YELLOW " 2. Use GitHub Actions for multi-platform builds"
print_message $YELLOW " 3. Build natively on the target platform" print_message $YELLOW " 3. Build natively on the target platform"
print_message $YELLOW " 4. Use 'make docker-buildx' for multi-arch Docker images" print_message $YELLOW " 4. Use 'make docker-buildx' for multi-arch Docker images"
fi fi
fi
return 1 return 1
fi fi