Skip to content

Commit

Permalink
added universal build support for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaladok committed Nov 1, 2024
1 parent f6d8a10 commit 108ce19
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 12 additions & 4 deletions tools/install-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ function download_dependencies() {
${BASE_DIR}/download-dependencies
}

function get_cmake_platform_options() {
local options=""
if [[ $(uname) == "Darwin" ]]; then
options="-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64'"
fi
echo "$options"
}

function build_gtest() {
# Build gtest
GTEST_DIR="$ROOT/build/local/src/gtest"
cd ${GTEST_DIR}/googletest-release-$GTEST_VERSION
$CMAKE -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -H.
$CMAKE -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -H. $(get_cmake_platform_options)
$MAKE -j4
$MAKE install
$MAKE clean
Expand All @@ -42,7 +50,7 @@ function build_libcheck() {
# Build Check
CHECK_DIR="$ROOT/build/local/src/check"
cd ${CHECK_DIR}/check-$CHECK_VERSION
$CMAKE -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -H.
$CMAKE -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -H. $(get_cmake_platform_options)
$MAKE -j4
$MAKE install
$MAKE clean
Expand All @@ -53,7 +61,7 @@ function build_protobuf() {
PROTOBUF_DIR="$ROOT/build/local/src/protobuf"
cd ${PROTOBUF_DIR}/protobuf-$PROTOBUF_VERSION

$CMAKE -Scmake -B . -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MODULE_COMPATIBLE=ON
$CMAKE -Scmake -B . -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MODULE_COMPATIBLE=ON $(get_cmake_platform_options)
$CMAKE --build . -j
$CMAKE --install . --prefix $PREFIX

Expand All @@ -63,7 +71,7 @@ function build_protobuf() {

# Protobuf plugins
cd "$ROOT/protobuf-plugin"
$CMAKE . -Bbuild -DProtobuf_DIR=$PREFIX/lib/cmake/protobuf
$CMAKE . -Bbuild -DProtobuf_DIR=$PREFIX/lib/cmake/protobuf $(get_cmake_platform_options)
$CMAKE --build build -j
$CMAKE --install build --prefix $PREFIX
$CMAKE --build build --target clean
Expand Down
8 changes: 7 additions & 1 deletion tools/rust-bindgen
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ create_xc_framework() {

cd rust

if isTargetSpecified "native"; then
if isTargetSpecified "native" && [[ $(uname) == "Darwin" ]]; then
echo "Generating Native target"
cargo build --target x86_64-apple-darwin --target aarch64-apple-darwin --release --lib

lipo $BUILD_FOLDER/x86_64-apple-darwin/release/$TARGET_NAME $BUILD_FOLDER/aarch64-apple-darwin/release/$TARGET_NAME -create -output $BUILD_FOLDER/release/$TARGET_NAME

else
echo "Generating Native target"
cargo build --release --lib
fi
Expand Down

0 comments on commit 108ce19

Please sign in to comment.