From df1da0d8bd3243a32abfd9925d30efab5a52236d Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Tue, 17 Dec 2024 16:57:29 +0800 Subject: [PATCH] Remove the dependencies on macOS frameworks --- .github/workflows/ci-pr-validation.yaml | 2 +- pkg/mac/build-static-library.sh | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml index 8debdca9..0ea40112 100644 --- a/.github/workflows/ci-pr-validation.yaml +++ b/.github/workflows/ci-pr-validation.yaml @@ -70,7 +70,7 @@ jobs: clang++ win-examples/example.cc -o dynamic.out -std=c++11 -arch ${{ matrix.arch }} -I $PULSAR_DIR/include -L $PULSAR_DIR/lib -Wl,-rpath $PULSAR_DIR/lib -lpulsar ./dynamic.out echo "Build with static library" - clang++ win-examples/example.cc -o static.out -std=c++11 -arch ${{ matrix.arch }} -I $PULSAR_DIR/include $PULSAR_DIR/lib/libpulsarwithdeps.a -framework SystemConfiguration -framework CoreServices -framework CoreFoundation + clang++ win-examples/example.cc -o static.out -std=c++11 -arch ${{ matrix.arch }} -I $PULSAR_DIR/include $PULSAR_DIR/lib/libpulsarwithdeps.a ./static.out check-completion: diff --git a/pkg/mac/build-static-library.sh b/pkg/mac/build-static-library.sh index 0f45c438..abb9e9a6 100755 --- a/pkg/mac/build-static-library.sh +++ b/pkg/mac/build-static-library.sh @@ -21,24 +21,32 @@ set -e cd `dirname $0`/../.. +if [[ -z $ARCH ]]; then + ARCH=$(uname -m) + echo "Use default ARCH: $ARCH" +fi if [[ $ARCH == "x86_64" ]]; then export VCPKG_TRIPLET=x64-osx - cp -f vcpkg-triplets/x64-osx.cmake vcpkg/triplets/x64-osx.cmake elif [[ $ARCH == "arm64" ]]; then export VCPKG_TRIPLET=arm64-osx - cp -f vcpkg-triplets/arm64-osx.cmake vcpkg/triplets/community/arm64-osx.cmake else echo "Invalid ARCH: $ARCH" exit 1 fi -CMAKE_OSX_ARCHITECTURES=$ARCH + +# Apply the patch to disable IPv6 when building curl, otherwise curl will depend on some +# frameworks (CoreFoundation, CoreServices, SystemConfiguration) that cannot be bundled +# into the static library `libpulsarwithdeps.a`. +# It requires the extra link options like `-framework CoreFoundation -framework CoreServices -framework SystemConfiguration`. +sed -i.bak 's/set(OPTIONS "")/set(OPTIONS -DENABLE_IPV6=OFF)/' vcpkg/ports/curl/portfile.cmake INSTALL_DIR=$PWD/pkg/mac/.install set -x cmake -B build-osx \ -DINTEGRATE_VCPKG=ON \ + -DVCPKG_OVERLAY_TRIPLETS=$PWD/vcpkg-triplets \ -DVCPKG_TARGET_TRIPLET=$VCPKG_TRIPLET \ - -DCMAKE_OSX_ARCHITECTURES=$CMAKE_OSX_ARCHITECTURES \ + -DCMAKE_OSX_ARCHITECTURES=$ARCH \ -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTS=OFF \ -DBUILD_PERF_TOOLS=OFF \