aboutsummaryrefslogtreecommitdiffstats
path: root/mypath/compile-tiny.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mypath/compile-tiny.sh')
-rwxr-xr-xmypath/compile-tiny.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/mypath/compile-tiny.sh b/mypath/compile-tiny.sh
new file mode 100755
index 0000000..2bfdada
--- /dev/null
+++ b/mypath/compile-tiny.sh
@@ -0,0 +1,61 @@
1#!/bin/bash
2
3##########################################################################
4# File Name : compile-tiny.sh
5# Encoding : utf-8
6# Author : We-unite
7# Email : weunite1848@gmail.com
8# Created Time : 2024-04-16 13:06:58
9##########################################################################
10
11set -e
12# 如果是root,报错
13if [ $(id -u) -eq 0 ]; then
14 echo "Do not run as root"
15 exit 1
16fi
17
18if [ $# -ne 2 ]; then
19 echo "Usage: $0 <src file> [armv8-a|armv7-a]"
20 exit 1
21fi
22
23native=~/app/native
24file=$1
25targetFile=${file%.*}
26arch=$2
27
28case $arch in
29 armv8-a)
30 compiler=$native/llvm/bin/aarch64-unknown-linux-ohos
31 targetPlatform=aarch64-linux-ohos
32 ;;
33 armv7-a)
34 compiler=$native/llvm/bin/armv7-unknown-linux-ohos
35 targetPlatform=arm-linux-ohos
36 ;;
37 *)
38 echo "Unsupported arch"
39 exit 1
40 ;;
41esac
42
43case ${file##*.} in
44 c)
45 compiler=$compiler-clang
46 ;;
47 cpp)
48 compiler=$compiler-clang++
49 ;;
50 *)
51 echo "Unsupported file type"
52 exit 1
53 ;;
54esac
55
56export CPATH=
57
58$compiler -o $targetFile $file -Wall \
59 --target=$targetPlatform \
60 --sysroot=$native/sysroot \
61 -march=$arch -mfloat-abi=softfp