summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaihaan Shouhell <raihaanhimself@gmail.com>2023-01-27 20:02:38 +0800
committerGitHub <noreply@github.com>2023-01-27 13:02:38 +0100
commit3a4f8250280486fb3793b55928793bf04dbde487 (patch)
treeb0f38c5d215665c07bee84dbab1e736c6e361030
parenteb75cdaae0aab357b41c2a892fa3b0b5f8424485 (diff)
downloadccache-3a4f8250280486fb3793b55928793bf04dbde487.tar.gz
ci: Build macOS universal binary (#1240)
-rw-r--r--.github/workflows/build.yaml20
-rw-r--r--CMakeLists.txt3
-rwxr-xr-xci/build-macos-binary24
-rw-r--r--cmake/Findzstd.cmake18
4 files changed, 57 insertions, 8 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index e7c099a6..363afdcb 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -220,6 +220,26 @@ jobs:
name: ${{ matrix.config.sys}}-${{ matrix.config.env }}-${{ matrix.config.compiler }}-testdir.tar.xz
path: testdir.tar.xz
+ build_macos_universal:
+ name: MacOS Universal Binary
+ runs-on: macos-12
+ env:
+ CMAKE_GENERATOR: Ninja
+ steps:
+ - name: Get source
+ uses: actions/checkout@v2
+ - name: Install Dependencies
+ run: |
+ HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 \
+ brew install ninja
+ - name: Build macOS universal binary
+ run: ci/build-macos-binary
+ - name: Archive universal binary
+ uses: actions/upload-artifact@v3
+ with:
+ name: macOS-binary
+ path: build_universal/ccache
+
specific_tests:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6407690e..06644f74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,6 +117,9 @@ option(ZSTD_FROM_INTERNET
option(HIREDIS_FROM_INTERNET
"Download and use libhiredis from the Internet if not available" ON)
+option(FORCE_INTERNET_ZSTD
+ "Only use libzstd from the Internet" OFF)
+
find_package(zstd 1.1.2 MODULE REQUIRED)
option(REDIS_STORAGE_BACKEND "Enable Redis remote storage" ON)
diff --git a/ci/build-macos-binary b/ci/build-macos-binary
new file mode 100755
index 00000000..44381d30
--- /dev/null
+++ b/ci/build-macos-binary
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -eu
+
+build() {
+ mkdir -p "build_$1"
+ cd "build_$1"
+ cmake -DFORCE_INTERNET_ZSTD=ON -DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" -DCMAKE_OSX_ARCHITECTURES="$1" -DCMAKE_SYSTEM_PROCESSOR="$1" ..
+ cmake --build .
+ cd ..
+}
+
+FILES=""
+set -- x86_64 arm64
+
+for i in "$@"; do
+ echo "Building $i"
+ build "$i"
+ FILES="${FILES} build_$i/ccache"
+done
+
+mkdir -p build_universal
+lipo -create $FILES -output build_universal/ccache
+lipo -info build_universal/ccache
diff --git a/cmake/Findzstd.cmake b/cmake/Findzstd.cmake
index a6d30a4f..2ce763d5 100644
--- a/cmake/Findzstd.cmake
+++ b/cmake/Findzstd.cmake
@@ -4,14 +4,16 @@ endif()
set(zstd_FOUND FALSE)
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
- pkg_search_module(PC_ZSTD libzstd)
- find_library(ZSTD_LIBRARY zstd HINTS ${PC_ZSTD_LIBDIR} ${PC_ZSTD_LIBRARY_DIRS})
- find_path(ZSTD_INCLUDE_DIR zstd.h HINTS ${PC_ZSTD_INCLUDEDIR} ${PC_ZSTD_INCLUDE_DIRS})
-else()
- find_library(ZSTD_LIBRARY zstd)
- find_path(ZSTD_INCLUDE_DIR zstd.h)
+if(NOT FORCE_INTERNET_ZSTD)
+ find_package(PkgConfig)
+ if(PKG_CONFIG_FOUND)
+ pkg_search_module(PC_ZSTD libzstd)
+ find_library(ZSTD_LIBRARY zstd HINTS ${PC_ZSTD_LIBDIR} ${PC_ZSTD_LIBRARY_DIRS})
+ find_path(ZSTD_INCLUDE_DIR zstd.h HINTS ${PC_ZSTD_INCLUDEDIR} ${PC_ZSTD_INCLUDE_DIRS})
+ else()
+ find_library(ZSTD_LIBRARY zstd)
+ find_path(ZSTD_INCLUDE_DIR zstd.h)
+ endif()
endif()
if(ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR)