Skip to content

Commit

Permalink
Apply the patch for vcpkg to disable IPv6 for curl's macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower committed Dec 17, 2024
1 parent 7908cc3 commit 382c9d9
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
fetch-depth: 0
submodules: recursive

- name: Apply the patch for vcpkg
run: ./build-support/apply-vcpkg-macos-curl-patch.sh

- name: Install dependencies
run: |
export ARCH=${{ matrix.arch }}
Expand All @@ -70,7 +73,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
38 changes: 38 additions & 0 deletions build-support/apply-vcpkg-macos-curl-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

cd `dirname $0`/..
set -ex

COMMIT_ID=$(grep "builtin-baseline" vcpkg.json | sed 's/"//g' | sed 's/,//' | awk '{print $2}')
cd vcpkg
git reset --hard $COMMIT_ID
git apply ../build-support/vcpkg-curl-patch.diff
git add ports/curl
git commit -m "Disable IPv6 for macOS in curl"
./bootstrap-vcpkg.sh
./vcpkg x-add-version --all
git add versions/
git commit -m "Update version"
COMMIT_ID=$(git log --pretty=oneline | head -n 1 | awk '{print $1}')

cd ..
sed -i.bak "s/.*builtin-baseline.*/ \"builtin-baseline\": \"$COMMIT_ID\",/" vcpkg.json
sed -i.bak "s/\"version>=\": \"8\.4\.0\"/\"version>=\": \"8.4.0#1\"/" vcpkg.json
27 changes: 27 additions & 0 deletions build-support/vcpkg-curl-patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/ports/curl/portfile.cmake b/ports/curl/portfile.cmake
index bdc544e9e..340d93865 100644
--- a/ports/curl/portfile.cmake
+++ b/ports/curl/portfile.cmake
@@ -64,6 +64,10 @@ if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND OPTIONS -DENABLE_UNICODE=ON)
endif()

+if(VCPKG_TARGET_IS_OSX)
+ list(APPEND OPTIONS -DENABLE_IPV6=OFF)
+endif()
+
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
diff --git a/ports/curl/vcpkg.json b/ports/curl/vcpkg.json
index e028d3897..a63858e34 100644
--- a/ports/curl/vcpkg.json
+++ b/ports/curl/vcpkg.json
@@ -1,6 +1,7 @@
{
"name": "curl",
"version": "8.4.0",
+ "port-version": 1,
"description": "A library for transferring data with URLs",
"homepage": "https://curl.se/",
"license": "curl AND ISC AND BSD-3-Clause",
10 changes: 6 additions & 4 deletions pkg/mac/build-static-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@
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

INSTALL_DIR=$PWD/pkg/mac/.install
set -x
cmake -B build-osx \
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 \
-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 382c9d9

Please sign in to comment.