Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddef05c

Browse files
committed
Merge branch 'feat/macos-x64' into android-mac
# Conflicts: # CMakeLists.txt # build.sh
2 parents e402cd7 + 35cbe10 commit ddef05c

4 files changed

Lines changed: 34 additions & 5 deletions

File tree

.github/workflows/builds.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ jobs:
5454
name: macos-arm64
5555
build_cmd: ./build.sh release-examples
5656
build_dir: build-release
57+
- os: macos-latest
58+
name: macos-x64
59+
build_cmd: ./build.sh release-examples --macos-arch x86_64
60+
build_dir: build-release
5761
- os: windows-latest
5862
name: windows-x64
5963
build_cmd: .\build.cmd release-examples
@@ -126,6 +130,10 @@ jobs:
126130
- name: Install Rust (stable)
127131
uses: dtolnay/rust-toolchain@stable
128132

133+
- name: Install Rust cross-compilation target
134+
if: matrix.name == 'macos-x64'
135+
run: rustup target add x86_64-apple-darwin
136+
129137
# ---------- Cache Cargo ----------
130138
- name: Cache Cargo registry
131139
uses: actions/cache@v4

.github/workflows/make-release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- os: macos-latest
3434
name: macos-arm64
3535
generator: Ninja
36+
- os: macos-latest
37+
name: macos-x64
38+
generator: Ninja
3639
- os: windows-latest
3740
name: windows-x64
3841
generator: "Visual Studio 17 2022"
@@ -125,6 +128,10 @@ jobs:
125128
- name: Install Rust (stable)
126129
uses: dtolnay/rust-toolchain@stable
127130

131+
- name: Install Rust cross-compilation target
132+
if: matrix.name == 'macos-x64'
133+
run: rustup target add x86_64-apple-darwin
134+
128135
# ---------- Cache Cargo ----------
129136
- name: Cache Cargo registry
130137
uses: actions/cache@v4
@@ -162,7 +169,11 @@ jobs:
162169
exit 1
163170
fi
164171
165-
./build.sh release-examples --version "$version" --bundle --prefix "$bundleDir"
172+
if [[ "${{ matrix.name }}" == "macos-x64" ]]; then
173+
./build.sh release-examples --version "$version" --bundle --prefix "$bundleDir" --macos-arch x86_64
174+
else
175+
./build.sh release-examples --version "$version" --bundle --prefix "$bundleDir"
176+
fi
166177
167178
# List bundle contents
168179
echo "Bundle contents:"
@@ -258,7 +269,7 @@ jobs:
258269
ls -la
259270
260271
# Create tar.gz for Linux and macOS
261-
for platform in linux-x64 linux-arm64 macos-arm64; do
272+
for platform in linux-x64 linux-arm64 macos-arm64 macos-x64; do
262273
dirName="livekit-sdk-${platform}-${VERSION}"
263274
if [[ -d "${dirName}" ]]; then
264275
echo "Creating archive for ${platform}..."

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ find_program(CARGO_EXECUTABLE NAMES cargo REQUIRED)
163163

164164
set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust)
165165

166-
# Detect Rust target triple for cross-compilation (e.g., Android NDK)
166+
# Detect Rust target triple for cross-compilation
167167
set(RUST_TARGET_TRIPLE "")
168168
if(ANDROID)
169169
if(CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a")
@@ -173,6 +173,12 @@ if(ANDROID)
173173
elseif(CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64")
174174
set(RUST_TARGET_TRIPLE "x86_64-linux-android")
175175
endif()
176+
elseif(APPLE AND CMAKE_OSX_ARCHITECTURES)
177+
if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
178+
set(RUST_TARGET_TRIPLE "x86_64-apple-darwin")
179+
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
180+
set(RUST_TARGET_TRIPLE "aarch64-apple-darwin")
181+
endif()
176182
endif()
177183

178184
if(RUST_TARGET_TRIPLE)
@@ -426,9 +432,9 @@ if(LIVEKIT_IS_TOPLEVEL)
426432
add_custom_command(
427433
TARGET livekit POST_BUILD
428434
COMMAND /usr/bin/install_name_tool
429-
-change "${RUST_ROOT}/target/release/deps/liblivekit_ffi.dylib"
435+
-change "${RUST_TARGET_DIR}/release/deps/liblivekit_ffi.dylib"
430436
"@rpath/liblivekit_ffi.dylib"
431-
-change "${RUST_ROOT}/target/debug/deps/liblivekit_ffi.dylib"
437+
-change "${RUST_TARGET_DIR}/debug/deps/liblivekit_ffi.dylib"
432438
"@rpath/liblivekit_ffi.dylib"
433439
"$<TARGET_FILE:livekit>"
434440
COMMENT "Fix dependency path in liblivekit.dylib -> liblivekit_ffi.dylib"

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ configure() {
181181
if [[ -n "${ANDROID_PLATFORM}" ]]; then
182182
extra_args+=("-DCMAKE_ANDROID_PLATFORM=${ANDROID_PLATFORM}")
183183
fi
184+
if [[ -n "${MACOS_ARCH}" ]]; then
185+
echo "==> Setting CMAKE_OSX_ARCHITECTURES=${MACOS_ARCH}"
186+
extra_args+=("-DCMAKE_OSX_ARCHITECTURES=${MACOS_ARCH}")
187+
fi
184188
if ((${#extra_args[@]})); then
185189
if ! cmake --preset "${PRESET}" "${extra_args[@]}"; then
186190
echo "Warning: CMake preset '${PRESET}' failed. Falling back to traditional configure..."

0 commit comments

Comments
 (0)