Refactor macOS build env setup and cleanup ARM64 handling

Simplifies and unifies environment variable setup for macOS ARM64 builds in both the GitHub Actions workflow and build.rs. Removes unnecessary unsafe blocks and redundant variable assignments, and ensures consistent deployment target and architecture settings for both Intel and Apple Silicon builds.
This commit is contained in:
Nikilite
2025-10-10 16:24:48 +02:00
parent 5406f99910
commit 6107eb7b35
2 changed files with 8 additions and 14 deletions

View File

@@ -37,11 +37,9 @@ jobs:
rustflags = ["-C", "link-arg=-mmacosx-version-min=13.0"]
EOF
- name: Install dependencies for ARM64 build
- name: Install dependencies
run: |
brew install cmake
echo "CMAKE_OSX_ARCHITECTURES=arm64" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV
- name: Clean previous builds
run: |
@@ -51,6 +49,7 @@ jobs:
- name: Build for Intel
run: |
export CMAKE_OSX_ARCHITECTURES=x86_64
export MACOSX_DEPLOYMENT_TARGET=13.0
cargo build --release --target x86_64-apple-darwin
- name: Build for Apple Silicon
@@ -61,7 +60,7 @@ jobs:
export CMAKE_OSX_ARCHITECTURES=arm64
export MACOSX_DEPLOYMENT_TARGET=13.0
cargo build --release --target aarch64-apple-darwin --verbose
cargo build --release --target aarch64-apple-darwin
- name: Check if binaries exist
run: |
@@ -97,7 +96,7 @@ jobs:
if: success()
run: |
VERSION="${{ github.event.inputs.version }}"
hdiutil create -volname "oboromi" -srcfolder "oboromi-$VERSION-macos" -ov -format UDZO "oboromi-$VERSION-macos-universal.dmg"
hdiutil create -volname "Oboromi" -srcfolder "oboromi-$VERSION-macos" -ov -format UDZO "oboromi-$VERSION-macos-universal.dmg"
- name: Upload macOS artifact
if: success()

View File

@@ -321,10 +321,8 @@ fn main() {
// Set environment variables for ARM64 builds
if target_os == "macos" && target_arch == "aarch64" {
unsafe {
cmake_cmd.env("CMAKE_OSX_ARCHITECTURES", "arm64");
cmake_cmd.env("MACOSX_DEPLOYMENT_TARGET", "13.0");
}
cmake_cmd.env("CMAKE_OSX_ARCHITECTURES", "arm64");
cmake_cmd.env("MACOSX_DEPLOYMENT_TARGET", "13.0");
}
let cmake_status = cmake_cmd.status();
@@ -351,6 +349,7 @@ fn main() {
.arg("--config")
.arg("Release");
// Only add Zycore and Zydis targets for x86_64
if target.contains("x86_64") {
build_cmd.arg("--target").arg("Zycore");
build_cmd.arg("--target").arg("Zydis");
@@ -364,9 +363,7 @@ fn main() {
if is_apple {
build_cmd.env("MACOSX_DEPLOYMENT_TARGET", "13.0");
if target_arch == "aarch64" {
unsafe {
build_cmd.env("CMAKE_OSX_ARCHITECTURES", "arm64");
}
build_cmd.env("CMAKE_OSX_ARCHITECTURES", "arm64");
}
}
@@ -438,7 +435,6 @@ fn main() {
}
if is_apple {
let _arch = if target.starts_with("aarch64-") { "arm64" } else { "x86_64" };
build
.flag("-arch").flag(if target.starts_with("aarch64-") { "arm64" } else { "x86_64" })
.define("__APPLE__", None);
@@ -501,7 +497,6 @@ fn main() {
}
if is_apple {
let _arch = if target.starts_with("aarch64-") { "arm64" } else { "x86_64" };
build2
.flag("-arch").flag(if target.starts_with("aarch64-") { "arm64" } else { "x86_64" })
.define("__APPLE__", None);