1#!/bin/bash
2
3# Copyright 2024 Google LLC
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# This script will build libyuv for the default ABI targets supported by
18# android. You must pass the path to the android NDK as a parameter to this
19# script.
20#
21# Android NDK: https://developer.android.com/ndk/downloads
22
23set -e
24
25if [ $# -ne 1 ]; then
26  echo "Usage: ${0} <path_to_android_ndk>"
27  exit 1
28fi
29
30#git clone --single-branch https://chromium.googlesource.com/libyuv/libyuv
31
32cd libyuv
33: # When changing the commit below to a newer version of libyuv, it is best to make sure it is being used by chromium,
34: # because the test suite of chromium provides additional test coverage of libyuv.
35: # It can be looked up at https://source.chromium.org/chromium/chromium/src/+/main:DEPS?q=libyuv.
36git checkout 464c51a0
37
38mkdir build.android
39cd build.android
40
41ABI_LIST="armeabi-v7a arm64-v8a x86 x86_64"
42for abi in ${ABI_LIST}; do
43  mkdir "${abi}"
44  cd "${abi}"
45  cmake ../.. \
46    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
47    -DCMAKE_TOOLCHAIN_FILE=${1}/build/cmake/android.toolchain.cmake \
48    -DCMAKE_BUILD_TYPE=Release \
49    -DANDROID_ABI=${abi}
50  make yuv
51  cd ..
52done
53
54cd ../..
55