Skip to content

Commit

Permalink
Remove the dependencies on macOS frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Dec 17, 2024
1 parent 796759e commit df1da0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions pkg/mac/build-static-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit df1da0d

Please sign in to comment.