Merge pull request #9 from rainyl/more-arch #33
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: android | |
on: | |
push: | |
tags: | |
- "*" | |
pull_request: | |
branches: ["main"] | |
env: | |
ANDROID_PLATFORM: android-24 | |
FFMPEG_ROOT: /tmp/ffmpeg | |
jobs: | |
android: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
opencv-version: [4.10.0] | |
abi: [armeabi-v7a, arm64-v8a, x86_64] | |
env: | |
COMMON_CMAKE_OPTIONS: | | |
-DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ | |
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ | |
-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ | |
-DANDROID_PLATFORM=$ANDROID_PLATFORM \ | |
-DCMAKE_INSTALL_PREFIX=install \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DANDROID_STL=c++_static \ | |
-DANDROID_ABI=${{ matrix.abi }} \ | |
-DANDROID_ARM_NEON=ON \ | |
-DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ | |
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ | |
-DWITH_ANDROID_MEDIANDK=ON \ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup-opencv-source | |
run: | | |
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv | |
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib | |
echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" | |
echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> "$GITHUB_ENV" | |
- name: setup ffmpeg | |
run: | | |
wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz | |
mkdir -p tmp | |
tar xf ffmpeg.tar.xz -C tmp --strip-components=1 | |
mkdir -p $FFMPEG_ROOT | |
cp -rf tmp/include $FFMPEG_ROOT | |
cp -rf tmp/lib/${{ matrix.abi }} $FFMPEG_ROOT/lib | |
cp -rf tmp/bin/${{ matrix.abi }} $FFMPEG_ROOT/bin | |
cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT | |
cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT | |
mkdir -p $FFMPEG_ROOT/cmake | |
cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ | |
rm -rf tmp | |
- name: build | |
run: | | |
cd ${{ env.SOURCE_DIR }} | |
mkdir build && cd build | |
cmake `cat ${{ github.workspace }}/options.txt` \ | |
${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ | |
-DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ | |
-DFFMPEG_ARCH="${{ matrix.abi }}" | |
cmake --build . -j $(nproc) | |
cmake --build . --target install | |
- name: package | |
run: | | |
mkdir -p ${{ env.PACKAGE_NAME }}/ | |
cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ | |
cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg | |
tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . | |
- name: test | |
run: | | |
cd test | |
mkdir build && cd build | |
cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ | |
-DANDROID_ABI="${{ matrix.abi }}" \ | |
-DANDROID_ARM_NEON=ON \ | |
-DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/sdk/native/jni \ | |
-DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ | |
.. | |
cmake --build . -j $(nproc) | |
- name: upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }} | |
path: ${{ env.PACKAGE_NAME }}.tar.gz | |
- name: release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
prerelease: false | |
files: | | |
${{ env.PACKAGE_NAME }}.tar.gz |