diff options
Diffstat (limited to 'mypath/compile-tiny.sh')
-rwxr-xr-x | mypath/compile-tiny.sh | 61 |
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 | |||
11 | set -e | ||
12 | # 如果是root,报错 | ||
13 | if [ $(id -u) -eq 0 ]; then | ||
14 | echo "Do not run as root" | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | if [ $# -ne 2 ]; then | ||
19 | echo "Usage: $0 <src file> [armv8-a|armv7-a]" | ||
20 | exit 1 | ||
21 | fi | ||
22 | |||
23 | native=~/app/native | ||
24 | file=$1 | ||
25 | targetFile=${file%.*} | ||
26 | arch=$2 | ||
27 | |||
28 | case $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 | ;; | ||
41 | esac | ||
42 | |||
43 | case ${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 | ;; | ||
54 | esac | ||
55 | |||
56 | export CPATH= | ||
57 | |||
58 | $compiler -o $targetFile $file -Wall \ | ||
59 | --target=$targetPlatform \ | ||
60 | --sysroot=$native/sysroot \ | ||
61 | -march=$arch -mfloat-abi=softfp | ||