GuoWenxue
2022-04-29 8bdd4bb9f08e38b61b47caa5aa50d6912772b289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
 
CROSSTOOL=arm-linux-gnueabihf-
 
# display in red
function pr_error() {
    echo ""
    echo -e "\033[40;31m --E-- $1 \033[0m"
    echo ""
}
 
# display in yellow
function pr_warn() {
    echo ""
    echo -e "\033[40;33m --W-- $1 \033[0m"
    echo ""
}
 
# display in green
function pr_info() {
    echo -e "\033[40;32m --I-- $1 \033[0m"
}
 
function check_depend()
{
    ARCH=`uname -m`
    echo ${ARCH} | grep "x86" > /dev/null
    if [ $? != 0 ] ; then
       pr_error  "This folder must compile on X86 server ";
       exit 1;
    fi
 
 
    ${CROSSTOOL}g++ -v > /dev/null 2>&1
    if [ $? != 0 ] ; then
        pr_error "Crosstool not installed, please install it by follow command:"
        pr_info  "sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf"
        exit 1;
    fi
}
 
function do_compile
{
    for dir in `ls`
    do
        if [ -f $dir/build*.sh ] ; then
            cd $dir
               bash ./build*.sh
            cd -
        fi
    done
}
 
function do_clean
{
    for dir in `ls`
    do
        if [ -f $dir/build*.sh ] ; then
            cd $dir
            bash ./build*.sh clean
            cd -
        fi
    done
 
    rm -rf install
}
 
if [[ $# == 1 ]] && [[ $1 == "clean" ]] ; then
    do_clean
    exit;
fi
 
check_depend
 
do_compile