Skip to content

Commit

Permalink
feat: Support OS X 15
Browse files Browse the repository at this point in the history
  • Loading branch information
skidder committed Jan 25, 2025
1 parent 5af03bd commit bd8c798
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 87 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
matrix:
runs-on:
- macos-14
- macos-15
- ubuntu-22.04
fail-fast: false
runs-on: ${{ matrix.runs-on }}
Expand Down
143 changes: 63 additions & 80 deletions .github/workflows/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ jobs:
name: deps-linux.tar.gz
path: deps-linux.tar.gz

macos:
name: macOS
runs-on: macos-14
macos-14:
name: macOS 14
runs-on:
- macos-14
steps:
- name: Check out repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -112,13 +113,67 @@ jobs:
- name: Create deps archive
run: |
tar -czf deps-macos.tar.gz deps/osx/
tar -czf deps-macos-14.tar.gz deps/osx/
- name: Upload deps artifact
uses: actions/upload-artifact@v4
with:
name: deps-macos.tar.gz
path: deps-macos.tar.gz
name: deps-macos-14.tar.gz
path: deps-macos-14.tar.gz

macos-15:
name: macOS 15
runs-on:
- macos-15
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Install build tools
run: |
brew install autoconf
brew install automake
brew install coreutils # for ffmpeg build
brew install libtool
- name: Build deps
run: |
echo "Starting dependency build..."
export MAKEFLAGS="-j$(nproc)"
./deps/build-deps-osx.sh
echo "Dependency build completed"
- run: |
git status
git diff
- name: Install Go
uses: actions/setup-go@v5
with:
cache: false
go-version: "1.23"

- name: Build and test lilliput with the new deps
run: |
go build
go test -v
- name: Generate build info
run: |
./deps/verify_deps.py generate \
--deps-dir deps/osx \
--platform macos \
--commit ${{ github.sha }}
- name: Create deps archive
run: |
tar -czf deps-macos-15.tar.gz deps/osx/
- name: Upload deps artifact
uses: actions/upload-artifact@v4
with:
name: deps-macos-15.tar.gz
path: deps-macos-15.tar.gz

verify:
name: Verify Build Artifacts
Expand All @@ -139,13 +194,13 @@ jobs:
- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: deps-macos.tar.gz
name: deps-macos-14.tar.gz
path: .

- name: Extract artifacts
run: |
tar xzf deps-linux.tar.gz
tar xzf deps-macos.tar.gz
tar xzf deps-macos-14.tar.gz
- name: Verify artifacts match checked-in deps
run: |
Expand All @@ -156,75 +211,3 @@ jobs:
python3 ./deps/verify_deps.py verify \
--deps-dir deps/osx \
--build-info deps/osx/build-info.json
update-deps:
name: Update Checked-in Dependencies
needs: [linux, macos]
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
timeout-minutes: 15

steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: deps-linux.tar.gz
path: .

- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: deps-macos.tar.gz
path: .

- name: Extract and update deps
run: |
# Remove existing deps directories to avoid stale files
rm -rf deps/linux/* deps/osx/*
tar xzf deps-linux.tar.gz
tar xzf deps-macos.tar.gz
- name: Commit updated deps
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git config --local commit.gpgsign false
# Stage each type of file explicitly
shopt -s nullglob # Handle case where globs don't match
# Binary files
for f in deps/*/lib/*.{so,so.*,dylib,dylib.*,a}; do
if [ -f "$f" ]; then
git add -f "$f"
fi
done
# Header files
for f in deps/*/include/**/*.h; do
if [ -f "$f" ]; then
git add -f "$f"
fi
done
# Build info
for f in deps/*/build-info.json; do
if [ -f "$f" ]; then
git add -f "$f"
fi
done
# Only commit if there are changes
if ! git diff --cached --quiet; then
git commit -m "Update native dependencies from ${{ github.sha }} [skip ci]
Dependencies built by workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
git push
else
echo "No changes to checked-in dependencies"
fi
36 changes: 30 additions & 6 deletions deps/build-deps-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PATH="/opt/homebrew/bin:$PATH"

# Function to check and install build tools
install_build_tools() {
for tool in automake libtool autoconf coreutils; do
for tool in automake libtool autoconf coreutils cmake; do
if ! command -v $tool >/dev/null 2>&1; then
echo "Installing $tool..."
brew install $tool
Expand Down Expand Up @@ -280,7 +280,10 @@ cmake $BASEDIR/opencv \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DCMAKE_C_FLAGS="-arch arm64 -I$PREFIX/include" \
-DCMAKE_CXX_FLAGS="-arch arm64 -I$PREFIX/include" \
-DCMAKE_CXX_FLAGS="-arch arm64 -I$PREFIX/include -stdlib=libc++ -std=c++11" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++" \
-DCMAKE_SHARED_LINKER_FLAGS="-stdlib=libc++" \
-DCMAKE_MODULE_LINKER_FLAGS="-stdlib=libc++" \
-DWITH_JPEG=ON \
-DJPEG_INCLUDE_DIR=$PREFIX/include \
-DJPEG_LIBRARY=$PREFIX/lib/libjpeg.a \
Expand Down Expand Up @@ -324,7 +327,10 @@ cmake $BASEDIR/opencv \
-DWITH_CAROTENE=OFF \
-DWITH_VIDEOTOOLBOX=ON \
-DBUILD_opencv_java=OFF \
-DBUILD_opencv_python=OFF
-DBUILD_opencv_python=OFF \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF

# Remove iOS-specific build files
sed -i '' "s|;$BASEDIR/opencv/modules/imgcodecs/include/opencv2/imgcodecs/ios.h||" $BASEDIR/build/opencv/CMakeCache.txt
Expand Down Expand Up @@ -368,7 +374,7 @@ cmake $BASEDIR/libyuv \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
-DCMAKE_C_FLAGS="-arch arm64 -fPIC -O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-arch arm64 -fPIC -O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-arch arm64 -fPIC -O3 -march=armv8-a+crc+crypto -mtune=apple-m1 -std=c++11" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
Expand All @@ -388,6 +394,17 @@ make install
# Remove any dylib if it was created
rm -f $PREFIX/lib/libyuv.dylib

# Detect macOS version
MACOS_VERSION=$(sw_vers -productVersion | cut -d. -f1)

# Configure C++ flags based on macOS version
if [ "$MACOS_VERSION" = "14" ]; then
CXX_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1 -stdlib=libc++ -std=c++11 -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1"
else
# macOS 15 needs more specific include paths and nostdinc++
CXX_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1 -stdlib=libc++ -std=c++11 -nostdinc++ -isystem /Library/Developer/CommandLineTools/usr/include/c++/v1 -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
fi

echo '\n--------------------'
echo 'Building libaom'
echo '--------------------\n'
Expand All @@ -399,7 +416,10 @@ cmake $BASEDIR/aom \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
-DCMAKE_C_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="-O3 -march=armv8-a+crc+crypto -mtune=apple-m1" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="-stdlib=libc++" \
-DCMAKE_SHARED_LINKER_FLAGS="-stdlib=libc++" \
-DCMAKE_MODULE_LINKER_FLAGS="-stdlib=libc++" \
-DENABLE_SHARED=0 \
-DENABLE_STATIC=1 \
-DENABLE_TESTS=0 \
Expand All @@ -409,7 +429,11 @@ cmake $BASEDIR/aom \
-DENABLE_VSX=0 \
-DCONFIG_MULTITHREAD=1 \
-DCONFIG_RUNTIME_CPU_DETECT=1 \
-DCMAKE_INSTALL_PREFIX=$PREFIX
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
make
make install

Expand Down
2 changes: 1 addition & 1 deletion deps/osx/share/OpenCV/OpenCVModules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endif()
add_library(opencv_core STATIC IMPORTED)

set_target_properties(opencv_core PROPERTIES
INTERFACE_LINK_LIBRARIES "/Users/runner/work/lilliput/lilliput/deps/osx/lib/libz.a"
INTERFACE_LINK_LIBRARIES "${SRCDIR}/deps/osx/lib/libz.a"
)

# Create imported target opencv_imgproc
Expand Down

0 comments on commit bd8c798

Please sign in to comment.