Skip to content

Commit

Permalink
feat(cmake): Use FetchContent and ExternalProject for local deps
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Feb 12, 2024
1 parent 8edba16 commit 9ebd5b3
Show file tree
Hide file tree
Showing 27 changed files with 703 additions and 373 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci-android-emulator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ jobs:
run: pip install meson
- name: Setup nasm
uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
- name: Build dav1d with the Android NDK
working-directory: ext
run: bash dav1d_android.sh ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build libyuv with the Android NDK
working-directory: ext
run: bash libyuv_android.sh ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Setup JDK
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/ci-android-jni.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ jobs:
run: pip install meson
- name: Setup nasm
uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
- name: Build dav1d with the Android NDK
working-directory: ext
run: bash dav1d_android.sh ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Build libyuv with the Android NDK
working-directory: ext
run: bash libyuv_android.sh ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Setup JDK
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
Expand Down
45 changes: 15 additions & 30 deletions .github/workflows/ci-disable-gtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
toolchain: stable
override: true

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-disable-gtest-${{ hashFiles('ext/*.cmd', 'ext/svt.sh') }}
- name: Install cargo-c
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec # v1.14.2
with:
Expand All @@ -59,30 +59,6 @@ jobs:
version: 2.15.05
- uses: seanmiddleditch/gha-setup-ninja@8b297075da4cd2a5f1fd21fe011b499edf06e9d2 # v4
- run: pip install meson
- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e aom.cmd
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e dav1d.cmd
- name: Build rav1e
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e rav1e.cmd
- name: Build SVT-AV1
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e svt.cmd
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libyuv.cmd
- name: Build libsharpyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libsharpyuv.cmd

- name: Prepare libavif (cmake)
run: >
Expand All @@ -96,6 +72,15 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=OFF
-DAVIF_ENABLE_WERROR=ON
- name: Cache cargo registry
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
continue-on-error: true
with:
path: ~/.cargo/registry/cache
key: cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-disable-gtest
restore-keys: |
cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-
cargo-registry-${{ runner.os }}-
- name: Build libavif (ninja)
working-directory: ./build
run: ninja
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/ci-linux-golden-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-golden-tests-${{ hashFiles('ext/aom.cmd', 'ext/libyuv.cmd', 'ext/libxml2.cmd', 'ext/mp4box.sh') }}
key: ${{ runner.os }}-golden-tests-${{ hashFiles('ext/mp4box.sh') }}

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec
with:
Expand All @@ -50,18 +51,6 @@ jobs:
with:
version: 2.15.05
- uses: seanmiddleditch/gha-setup-ninja@8b297075da4cd2a5f1fd21fe011b499edf06e9d2 # v4
- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e aom.cmd
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libyuv.cmd
- name: Build libxml2
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libxml2.cmd
- name: Build mp4box
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci-unix-shared-installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ jobs:
- name: Set GCC & G++ compiler (on Linux)
if: runner.os == 'Linux'
run: echo "CC=gcc-${{matrix.gcc}}" >> $GITHUB_ENV && echo "CXX=g++-${{matrix.gcc}}" >> $GITHUB_ENV

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-shared-installed-${{ hashFiles('ext/*.cmd') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec # v1.14.2
with:
Expand All @@ -59,11 +52,6 @@ jobs:
# `sudo apt-get install googletest libgtest-dev` leads to the following:
# "libgtest.a(gtest-all.cc.o): undefined reference to `std::__throw_bad_array_new_length()'"
# so build it locally instead.
- name: Build GoogleTest
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e googletest.cmd

- name: Prepare libavif (cmake)
run: >
mkdir build && cd build
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/ci-unix-shared-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ jobs:
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.x'

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-shared-local-${{ hashFiles('ext/*.cmd') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec # v1.14.2
with:
Expand All @@ -58,26 +51,6 @@ jobs:
- run: pip install meson
- name: Print ImageMagick version
run: convert --version
- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e aom.cmd
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e dav1d.cmd
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libyuv.cmd
- name: Build libsharpyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libsharpyuv.cmd
- name: Build GoogleTest
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e googletest.cmd

- name: Prepare libavif (cmake)
run: >
Expand Down
50 changes: 15 additions & 35 deletions .github/workflows/ci-unix-static-av2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install cargo-c
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
- name: Cache external dependencies
id: cache-ext
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-static-av2-${{ hashFiles('ext/*.cmd', 'ext/svt.sh') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec # v1.14.2
with:
Expand All @@ -53,35 +53,6 @@ jobs:
version: 2.15.05
- uses: seanmiddleditch/gha-setup-ninja@8b297075da4cd2a5f1fd21fe011b499edf06e9d2 # v4
- run: pip install meson
- name: Build avm
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e avm.cmd
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e dav1d.cmd
- name: Build rav1e
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e rav1e.cmd
- name: Build SVT-AV1
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e svt.cmd
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libyuv.cmd
- name: Build libsharpyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libsharpyuv.cmd
- name: Build GoogleTest
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
# Note: "apt install googletest" is sometimes insufficient for find_package(GTest) so build in ext/ instead.
run: bash -e googletest.cmd

- name: Prepare libavif (cmake)
run: >
Expand All @@ -98,6 +69,15 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
-DAVIF_ENABLE_WERROR=ON
- name: Cache cargo registry
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
continue-on-error: true
with:
path: ~/.cargo/registry/cache
key: cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-unix-static-av2
restore-keys: |
cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-
cargo-registry-${{ runner.os }}-
- name: Build libavif (ninja)
working-directory: ./build
run: ninja
Expand Down
74 changes: 28 additions & 46 deletions .github/workflows/ci-unix-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,28 @@ jobs:
profile: minimal
toolchain: stable
override: true
- name: Install cargo-c (linux)
if: matrix.os == 'ubuntu-latest'
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
- name: Install cargo-c (mac)
if: matrix.os == 'macos-latest'
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-macos.zip
run: |
curl -sLo $CARGO_C_FILE $LINK/$CARGO_C_FILE
unzip -o $CARGO_C_FILE -d ~/.cargo/bin
rm $CARGO_C_FILE
- name: Cache external dependencies
id: cache-ext
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
with:
path: ext
key: ${{ runner.os }}-${{ matrix.build-type }}-${{ hashFiles('ext/*.cmd', 'ext/svt.sh') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@d06b37b47cfd043ec794ffa3e40e0b6b5858a7ec # v1.14.2
with:
# CMake version 3.17 is required to build libwebp (which libsharpyuv is part of) on macOS.
cmake-version: '3.17.x'
# CMake version 3.18 is required to build libxml2
cmake-version: '3.18.x'
- name: Print cmake version
run: cmake --version
- uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
Expand All @@ -56,44 +66,6 @@ jobs:
- run: pip install meson
- name: Print ImageMagick version
run: convert --version
- name: Build aom
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e aom.cmd
- name: Build dav1d
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e dav1d.cmd
- name: Build rav1e
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e rav1e.cmd
- name: Build SVT-AV1
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e svt.cmd
- name: Build libgav1
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libgav1.cmd
- name: Build libyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libyuv.cmd
- name: Build libsharpyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libsharpyuv.cmd
- name: Build libargparse
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: bash -e libargparse.cmd
- name: Build GoogleTest
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
# Note: "apt install googletest" is sometimes insufficient for find_package(GTest) so build in ext/ instead.
run: bash -e googletest.cmd

- name: Prepare libavif (cmake)
run: >
mkdir build && cd build
Expand All @@ -104,12 +76,22 @@ jobs:
-DAVIF_CODEC_RAV1E=LOCAL -DAVIF_CODEC_SVT=LOCAL
-DAVIF_CODEC_LIBGAV1=LOCAL -DAVIF_LIBYUV=LOCAL
-DAVIF_LIBSHARPYUV=LOCAL
-DAVIF_LOCAL_LIBARGPARSE=ON
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON
-DAVIF_ENABLE_WERROR=ON
- name: Cache cargo registry
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
continue-on-error: true
with:
path: ~/.cargo/registry/cache
key: cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-unix-static
restore-keys: |
cargo-registry-${{ runner.os }}-${{ hashFiles('ext/rav1e/Cargo.lock') }}-
cargo-registry-${{ runner.os }}-
- name: Build libavif (ninja)
working-directory: ./build
run: ninja
Expand Down
Loading

0 comments on commit 9ebd5b3

Please sign in to comment.