Skip to content

Commit

Permalink
feat(cmake): Use FetchContent and ExternalProject for local deps (#1744)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino authored Apr 11, 2024
1 parent 7bc40b1 commit f1b936d
Show file tree
Hide file tree
Showing 27 changed files with 996 additions and 370 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@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
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@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1
with:
Expand All @@ -57,30 +57,6 @@ jobs:
- uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
- 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 @@ -94,6 +70,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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b
with:
Expand All @@ -48,18 +49,6 @@ jobs:
run: cmake --version
- uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
- 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
14 changes: 0 additions & 14 deletions .github/workflows/ci-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,8 @@ jobs:
libyuv:p
ninja:p
zlib:p
- name: Cache external dependencies
id: cache-ext
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ext
key: ${{ matrix.sys }}-mingw-${{ hashFiles('ext/*.cmd') }}
- name: Print cmake version
run: cmake --version
- name: Build libsharpyuv
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: ./libsharpyuv.cmd
- name: Build GoogleTest
if: steps.cache-ext.outputs.cache-hit != 'true'
working-directory: ./ext
run: ./googletest.cmd

- name: Prepare libavif (cmake)
run: >
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 @@ -33,13 +33,6 @@ jobs:
# TODO(yguyon): Install libyuv (not available with brew).
if: runner.os == 'macOS'
run: echo "CMAKE_AVIF_FLAGS=\"-DAVIF_LIBYUV=OFF\"" >> $GITHUB_ENV

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ext
key: ${{ runner.os }}-shared-installed-${{ hashFiles('ext/*.cmd') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1
with:
Expand All @@ -62,11 +55,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@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.x'

- name: Cache external dependencies
id: cache-ext
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ext
key: ${{ runner.os }}-shared-local-${{ hashFiles('ext/*.cmd') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1
with:
Expand All @@ -56,26 +49,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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ext
key: ${{ runner.os }}-static-av2-${{ hashFiles('ext/*.cmd', 'ext/svt.sh') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1
with:
Expand All @@ -51,35 +51,6 @@ jobs:
- uses: ilammy/setup-nasm@13cbeb366c45c4379d3478cdcbadd8295feb5028 # v1.5.1
- 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 @@ -96,6 +67,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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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
69 changes: 25 additions & 44 deletions .github/workflows/ci-unix-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ext
key: ${{ runner.os }}-${{ matrix.build-type }}-${{ hashFiles('ext/*.cmd', 'ext/svt.sh') }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@959f1116cf9f1ae42fff8ec1a4aaae6d4a0e348b # v2.0.1
with:
Expand All @@ -54,44 +64,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 @@ -108,6 +80,15 @@ jobs:
-DAVIF_ENABLE_EXPERIMENTAL_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_AVIR=ON
-DAVIF_ENABLE_WERROR=ON
- name: Cache cargo registry
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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 f1b936d

Please sign in to comment.