Skip to content

Commit 94b99f5

Browse files
committed
support compile yuv for android
1 parent 58b5fe7 commit 94b99f5

File tree

4 files changed

+72
-12
lines changed

4 files changed

+72
-12
lines changed

do-compile/android/any.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function do_compile() {
6767
}
6868

6969
function do_clean() {
70-
70+
7171
if [[ -d $MR_BUILD_SOURCE ]];then
7272
echo "git clean:$MR_BUILD_SOURCE"
7373
cd $MR_BUILD_SOURCE
@@ -90,6 +90,7 @@ function main() {
9090
for arch in $MR_ACTIVE_ARCHS; do
9191
export _MR_ARCH=$arch
9292
source $MR_SHELL_TOOLS_DIR/export-android-build-env.sh
93+
echo "---"
9394
do_clean $arch
9495
done
9596

do-compile/android/yuv.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Copyright (C) 2021 Matt Reach<qianlongxu@gmail.com>
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+
# https://stackoverflow.com/questions/6003374/what-is-cmake-equivalent-of-configure-prefix-dir-make-all-install
18+
# https://cmake.org/cmake/help/v3.28/variable/CMAKE_OSX_SYSROOT.html
19+
# https://cmake.org/cmake/help/v3.14/manual/cmake-toolchains.7.html#switching-between-device-and-simulator
20+
# https://stackoverflow.com/questions/27660048/cmake-check-if-mac-os-x-use-apple-or-apple
21+
# https://stackoverflow.com/questions/49711514/building-c-projects-which-have-cmake-build-files-for-android-using-ndk
22+
23+
set -e
24+
25+
THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd)
26+
cd "$THIS_DIR"
27+
28+
echo "----------------------"
29+
echo "[*] configurate $LIB_NAME"
30+
echo "----------------------"
31+
32+
build="${MR_BUILD_SOURCE}/_tmp"
33+
34+
rm -rf "$build"
35+
mkdir -p "$build"
36+
cd "$build"
37+
38+
cmake -S ${MR_BUILD_SOURCE} \
39+
-DCMAKE_INSTALL_PREFIX=${MR_BUILD_PREFIX} \
40+
-DCMAKE_TOOLCHAIN_FILE=${MR_ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \
41+
-DANDROID_NDK=${MR_ANDROID_NDK_HOME} \
42+
-DANDROID_ABI=${MR_ANDROID_ABI} \
43+
-DANDROID_PLATFORM=android-${MR_ANDROID_API} \
44+
-DANDROID_STL=c++_shared \
45+
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${LIB1_DIRECTORY}/libs/${MR_ANDROID_ABI}
46+
47+
echo "----------------------"
48+
echo "[*] compile $LIB_NAME"
49+
echo "----------------------"
50+
51+
cmake --build . --target $LIB_NAME --config Release -- CODE_SIGNING_ALLOWED=NO
52+
cmake --install .

do-compile/apple/yuv.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,15 @@ echo "MR_DEBUG:$MR_DEBUG"
3838
echo "===check env end==="
3939

4040

41-
toolchain=$MR_SHELL_TOOLS_DIR/ios.toolchain.cmake
42-
4341
echo "----------------------"
4442
echo "[*] configurate $LIB_NAME"
4543
echo "[*] cmake config $cfg"
46-
echo "[*] cmake toolchain $toolchain"
4744
echo "----------------------"
4845

4946
build="${MR_BUILD_SOURCE}/_tmp"
5047

5148
rm -rf "$build"
5249
mkdir -p "$build"
53-
5450
cd "$build"
5551

5652
pf=
@@ -78,7 +74,11 @@ elif [[ "$MR_PLAT" == 'macos' ]];then
7874
fi
7975
fi
8076

81-
cmake -S ${MR_BUILD_SOURCE} -DCMAKE_INSTALL_PREFIX=${MR_BUILD_PREFIX} -GXcode -DCMAKE_TOOLCHAIN_FILE=$toolchain -DPLATFORM=$pf
77+
cmake -S ${MR_BUILD_SOURCE} \
78+
-DCMAKE_INSTALL_PREFIX=${MR_BUILD_PREFIX} \
79+
-DCMAKE_TOOLCHAIN_FILE="${MR_SHELL_TOOLS_DIR}/ios.toolchain.cmake" \
80+
-DPLATFORM=$pf \
81+
-GXcode
8282

8383
echo "----------------------"
8484
echo "[*] compile $LIB_NAME"

tools/export-android-build-env.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,32 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17-
#https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script
17+
# https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script
18+
# https://developer.android.com/ndk/guides/abis?hl=zh-cn#cmake_1
19+
20+
21+
export MR_ANDROID_API=23
1822

1923
case $_MR_ARCH in
2024
*v7a)
2125
export MR_TRIPLE=armv7a-linux-androideabi$MR_ANDROID_API
2226
export MR_FF_ARCH=arm
27+
export MR_ANDROID_ABI=armeabi-v7a
2328
;;
2429
x86)
2530
export MR_TRIPLE=i686-linux-android$MR_ANDROID_API
2631
export MR_FF_ARCH=i686
32+
export MR_ANDROID_ABI=x86
2733
;;
2834
x86_64)
2935
export MR_TRIPLE=x86_64-linux-android$MR_ANDROID_API
3036
export MR_FF_ARCH=x86_64
37+
export MR_ANDROID_ABI=x86_64
3138
;;
3239
arm64*)
3340
export MR_TRIPLE=aarch64-linux-android$MR_ANDROID_API
3441
export MR_FF_ARCH=aarch64
42+
export MR_ANDROID_ABI=arm64-v8a
3543
;;
3644
*)
3745
echo "unknown architecture $_MR_ARCH";
@@ -56,9 +64,8 @@ else
5664
export MR_NDK_REL=$(grep -m 1 -o '^## r[0-9]*.*' $ANDROID_NDK_HOME/CHANGELOG.md | awk '{print $2}')
5765
fi
5866

59-
export MR_ANDROID_API=23
60-
61-
export MR_TOOLCHAIN_ROOT="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/${MR_HOST_TAG}"
67+
export MR_ANDROID_NDK_HOME="$ANDROID_NDK_HOME"
68+
export MR_TOOLCHAIN_ROOT="$MR_ANDROID_NDK_HOME/toolchains/llvm/prebuilt/${MR_HOST_TAG}"
6269
export PATH="${MR_TOOLCHAIN_ROOT}/bin:$PATH"
6370
export MR_SYS_ROOT="${MR_TOOLCHAIN_ROOT}/sysroot"
6471

@@ -95,10 +102,10 @@ echo "MR_ANDROID_NDK : [$MR_NDK_REL]"
95102
echo "MR_BUILD_NAME : [$MR_BUILD_NAME]"
96103
echo "MR_BUILD_SOURCE : [$MR_BUILD_SOURCE]"
97104
echo "MR_BUILD_PREFIX : [$MR_BUILD_PREFIX]"
98-
echo "MR_ANDROID_NDK_TOOLCHAIN: [$MR_TOOLCHAIN_ROOT]"
105+
echo "MR_ANDROID_NDK_HOME: [$MR_ANDROID_NDK_HOME]"
99106

100107
#
101108
THIS_DIR=$(DIRNAME=$(dirname "${BASH_SOURCE[0]}"); cd "${DIRNAME}"; pwd)
102109
source "$THIS_DIR/export-android-pkg-config-dir.sh"
103110

104-
echo "PKG_CONFIG_LIBDIR:$PKG_CONFIG_LIBDIR"
111+
echo "PKG_CONFIG_LIBDIR: [$PKG_CONFIG_LIBDIR]"

0 commit comments

Comments
 (0)