aboutsummaryrefslogtreecommitdiffstats
path: root/mypath/compile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mypath/compile.sh')
-rwxr-xr-xmypath/compile.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/mypath/compile.sh b/mypath/compile.sh
new file mode 100755
index 0000000..2948e8f
--- /dev/null
+++ b/mypath/compile.sh
@@ -0,0 +1,41 @@
1#!/bin/bash
2
3##########################################################################
4# File Name : compile.sh
5# Encoding : utf-8
6# Author : We-unite
7# Email : weunite1848@gmail.com
8# Created Time : 2024-02-29 15:19:15
9##########################################################################
10
11set -e
12
13if [ $UID -eq 0 ]; then
14 echo "Please do not run this script as root"
15 exit 1
16fi
17
18if [ $# -ne 2 ]; then
19 echo "Usage: $0 <static|shared> <v7|v8>"
20 exit 1
21fi
22
23if [ $2 == "v8" ]; then
24 arch=arm64-v8a
25elif [ $2 == "v7" ]; then
26 arch=armeabi-v7a
27else
28 echo "Usage: $0 <static|shared> <v7|v8>"
29 exit 1
30fi
31
32link=$1 # static or shared
33native_path=~/app/native
34
35export PATH=$native_path/build-tools/cmake/bin:$PATH
36# 清空CPATH,防止影响编译
37export CPATH=
38
39# 使用cmake编译,编译生成的文件运行在rk3568上
40cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake)
41cmake --build build