Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完善针对android构建的脚本,以及其他优化 #88

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

build/
.vscode
4 changes: 4 additions & 0 deletions libmetartc7/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ project(libmetartc7)

add_definitions(-D__STDC_FORMAT_MACROS)

if(ANDROID)
add_definitions(-DYang_OS_ANDROID)
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu11 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=gnu++11 ")
set(HOME_BASE_REL "../")
Expand Down
65 changes: 41 additions & 24 deletions libmetartc7/cmake_android.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
NDK_ROOT=/home/yang/pro/ndk
API=29
rm -rf build
mkdir build
cd build
#!/usr/bin/env bash

NDK_ROOT=/media/gaojie/lvm2/Android/Sdk/ndk/28.0.12433566/
API=34

#arm64-v8a armeabi x86_64
ARCH=arm64-v8a
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_NDK=$NDK_ROOT -DCMAKE_SYSTEM_NAME=Android -DANDROID_PLATFORM=android-${API} -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${ARCH} -DAndroid=ON -DANDROID_STL=c++_static -DCMAKE_CXX_STANDARD=11 -DANDROID_NATIVE_API_LEVEL=${API} ..
make
if [ ! -d "../../bin/lib_android/arm64-v8a" ] ; then
mkdir -p ../../bin/lib_android/arm64-v8a
fi
cp ./libmetartc7.a ../../bin/lib_android/arm64-v8a/

cd ..
rm -rf build
mkdir build
cd build
ARCH=x86_64
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_NDK=$NDK_ROOT -DCMAKE_SYSTEM_NAME=Android -DANDROID_PLATFORM=android-${API} -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${ARCH} -DAndroid=ON -DANDROID_STL=c++_static -DCMAKE_CXX_STANDARD=11 -DANDROID_NATIVE_API_LEVEL=${API} ..
make
if [ ! -d "../../bin/lib_android/x86_64" ] ; then
mkdir -p ../../bin/lib_android/x86_64
fi
cp ./libmetartc7.a ../../bin/lib_android/x86_64/
ARCHS="arm64-v8a armeabi-v7a x86_64"

build() {
ARCH=$1

echo "Build for $ARCH"
BUILD_DIR=build/$ARCH
echo "Build dir is: $BUILD_DIR"

#clean build dir
# rm -rf $BUILD_DIR

# configuration
cmake -B $BUILD_DIR \
-DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=11 \
-DANDROID_NDK=$NDK_ROOT \
-DANDROID_PLATFORM=android-${API} \
-DANDROID_ABI=${ARCH} -DAndroid=ON \
-DANDROID_STL=c++_static \
-DANDROID_NATIVE_API_LEVEL=${API} \
-DYang_OS_ANDROID=ON

# build
cmake --build $BUILD_DIR

}


for arch in $ARCHS
do
build $arch
done