Providing build option to disable BLE server
[platform/upstream/iotivity.git] / resource / csdk / stack / samples / tizen / build / gbsbuild.sh
1 #!/bin/sh
2
3 spec=`ls ./resource/csdk/stack/samples/tizen/build/packaging/*.spec`
4 version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
5
6 name=`echo $name|cut -d" " -f 1`
7 version=`echo $version|cut -d" " -f 1`
8
9 name=oicri
10 gbsarch=${gbsarch:=armv7l}
11
12 echo $1
13 export TARGET_TRANSPORT=$1
14
15 echo $2
16 export SECURED=$2
17
18 echo $3
19 export BUILD_SAMPLE=$3
20
21 echo $4
22 export RELEASE=$4
23
24 echo $5
25 export LOGGING=$5
26
27 echo $6
28 export ROUTING=$6
29
30 echo $7
31 export WITH_TCP=$7
32
33 echo $8
34 export WITH_PROXY=$8
35
36 echo $9
37 export WITH_MQ=$9
38
39 echo $10
40 export DISABLE_BLE_SERVER=$10
41
42 echo $TARGET_TRANSPORT
43 echo $BUILD_SAMPLE
44 echo $WITH_MQ
45
46 rm -rf $name-$version
47
48 builddir=`pwd`
49 sourcedir=`pwd`
50
51 echo `pwd`
52
53 rm -rf ./tmp
54 mkdir ./tmp
55 mkdir ./tmp/extlibs/
56 mkdir ./tmp/packaging
57 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
58 cp -Rf ./extlibs/mbedtls $sourcedir/tmp/extlibs
59 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
60 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
61 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
62 cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
63 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
64 cp -R ./resource/csdk/stack/samples/tizen/build/packaging/*.spec $sourcedir/tmp/packaging
65 cp -R ./resource $sourcedir/tmp/
66 cp -R ./build_common/external_libs.scons $sourcedir/tmp/
67 mkdir -p $sourcedir/tmp/build_common/
68 cp -a ./build_common/*.scons $sourcedir/tmp/build_common/
69
70 # copy dependency RPMs and conf files for tizen build
71 cp ./tools/tizen/*.rpm $sourcedir/tmp
72 cp ./tools/tizen/*.rpm $sourcedir/tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
73 cp ./tools/tizen/.gbs.conf ./tmp
74 cp ./tools/tizen/.gbs.conf ./tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
75
76 cd $sourcedir
77 cd ./resource/csdk/stack/samples/tizen/build/
78
79 cp -R ./* $sourcedir/tmp/
80 rm -f $sourcedir/tmp/SConscript
81 cp SConstruct $sourcedir/tmp/
82 cp scons/SConscript $sourcedir/tmp/scons/
83
84 mkdir -p $sourcedir/tmp/iotivityconfig
85 cd $sourcedir/build_common/
86 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
87 cp -R ./SConscript $sourcedir/tmp/
88
89 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
90
91 cd $sourcedir/tmp
92
93 echo `pwd`
94 # Prepare mbedTLS dependency
95 $SHELL ./extlibs/mbedtls/prep.sh
96
97 # Prepare TinyCBOR dependency
98 $SHELL ./extlibs/tinycbor/prep.sh
99
100 whoami
101 # Initialize Git repository
102 if [ ! -d .git ]; then
103    git init ./
104    git config user.email "you@example.com"
105    git config user.name "Your Name"
106    git add ./
107    git commit -m "Initial commit"
108 fi
109
110 gbsprofile=${gbsprofile:=profile.tizen}
111 gbscommand_prefix="gbs build -A ${gbsarch} -P ${gbsprofile} "
112 nproc=$(expr 1 + $(expr `nproc --ignore=1` / 2 ) )
113 gbscommand_prefix=${gbscommand_prefix}" --define '_smp_mflags -j${nproc}'"
114
115 echo "Calling core gbs build command"
116 gbscommand=${gbscommand_prefix}" -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6' --define 'WITH_TCP $7' --define 'WITH_PROXY $8' --define 'WITH_MQ $9' --define 'DISABLE_BLE_SERVER $10'"
117 echo $gbscommand
118 if eval $gbscommand; then
119    echo "Core build is successful"
120 else
121    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
122    cd $sourcedir
123    rm -rf $sourcedir/tmp
124    exit 1
125 fi
126
127 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
128    cd resource/csdk/stack/samples/tizen/SimpleClientServer
129    echo `pwd`
130    # Initialize Git repository
131    if [ ! -d .git ]; then
132       git init ./
133       git config user.email "you@example.com"
134       git config user.name "Your Name"
135       git add ./
136       git commit -m "Initial commit"
137    fi
138    echo "Calling sample gbs build command"
139    gbscommand=${gbscommand_prefix}" -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6' --define 'WITH_TCP $7' --define 'WITH_PROXY $8' --define 'WITH_MQ $9'"
140    echo $gbscommand
141    if eval $gbscommand; then
142       echo "Sample build is successful"
143    else
144       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
145       exit 1
146    fi
147 else
148         echo "Sample build is not enabled"
149 fi
150
151 cd $sourcedir
152 rm -rf $sourcedir/tmp
153
154 exit 0