summaryrefslogtreecommitdiff
path: root/build-im-sc-android64.sh
blob: c8b41b46ff0df8d75893312bdbb499d8c7a973e5 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash

###### Please specify below ######
CLEAN_CMD="scons -c"
BUILD_CMD="scons TARGET_OS=android TARGET_ARCH=arm64-v8a TARGET_TRANSPORT=IP,BLE WITH_TCP=1 WITH_CLOUD=1 MULTIPLE_OWNER=1 SECURED=1 LOGGING=1 RELEASE=1 ANDROID_HOME=$ANDROID_HOME ANDROID_NDK=$ANDROID_NDK ANDROID_GRADLE=$ANDROID_GRADLE"
REMOVE_CMD="rm -rf out"
REMOVE_THIRDPARTY_CMD="rm service/third_party_libs.scons"
CONF_CMD=""
SPEC_CMD=""

# For Git
CLONE_CMD="git clone http://suprem.sec.samsung.net/gerrit/IoTivity samsung_iotivity"
FETCH_CMD="git fetch -p"
CHECKOUT_CMD="git checkout -f"
CHERRYPICK_PREFIX="git fetch http://suprem.sec.samsung.net/gerrit/IoTivity"
CHERRYPICK_CMD="git cherry-pick FETCH_HEAD"

msg_hello()
{
    echo "***********************************************************************"
    echo "*                                                                     *"
    echo "*                         IoTivity Build Start.                       *"
    echo "*                                                                     *"
    echo "***********************************************************************"
}

msg_error()
{
    echo ---------------------------------------------------------------------
    echo "Fail to Build, Check Last Step. [$_STEP]"
    echo ---------------------------------------------------------------------
    exit 2
}

error_check()
{
    if [ $? != 0 ]
    then
       msg_error
    fi
}

# Check commit_info
_STEP=COMMIT
if [ "" = "$1" ];then
    msg_error
fi
COMMIT_ID=$(awk '/^commit_id:/{print $2}' "$1")
echo COMMIT ID is $COMMIT_ID
error_check
if [ 0 == ${#COMMIT_ID} ];then
    msg_error
fi

# Cherry pick_info
_STEP=CHERRYPICK
CHERRYPICK_ID=$(awk '/^cherrypick_cmd_id:/{print $5}' "$1")
for cherry_pic_arr in $CHERRYPICK_ID
do
    echo CHERRY_PICK_ID is $cherry_pic_arr
    error_check
done

# Check Source Code
_STEP=INIT
msg_hello
if [ ! -d resource/csdk ];then
    if [ ! -d samsung_iotivity ];then
        echo $CLONE_CMD
        $CLONE_CMD
        error_check
    fi
    cd ./samsung_iotivity
fi
error_check

_STEP=FETCH
echo $FETCH_CMD
$FETCH_CMD
error_check

_STEP=CLEAN
if [ -d out ]; then
    echo $REMOVE_THIRDPARTY_CMD
    $REMOVE_THIRDPARTY_CMD
    echo $CLEAN_CMD
    $CLEAN_CMD
    error_check
    echo $REMOVE_CMD
    $REMOVE_CMD
    error_check
fi

_STEP=CHECKOUT
echo $CHECKOUT_CMD $COMMIT_ID
$CHECKOUT_CMD $COMMIT_ID
error_check

_STEP=CHERRYPICK
if $isCherrypickFile ; then
    for arr_cherry_pick_cmd in $CHERRYPICK_ID; do
        echo $CHERRYPICK_PREFIX $arr_cherry_pick_cmd 
        $CHERRYPICK_PREFIX $arr_cherry_pick_cmd
        echo $CHERRYPICK_CMD
        $CHERRYPICK_CMD
        error_check
    done
fi

_STEP=CONF
echo $CONF_CMD
$CONF_CMD
echo $SPEC_CMD
$SPEC_CMD
error_check

_STEP=BUILD
echo $BUILD_CMD
if [ $ANDROID_HOME ];then
    $BUILD_CMD
    error_check
else
    echo "Please add ANDROID_HOME in .bashrc file."
    msg_error
fi