a87ba42162f8b3404630705d8c35483a4746bbce
[contrib/iotivity.git] / gbsbuild.sh
1 #!/bin/sh
2
3 spec=`ls tools/tizen/*.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=iotivity
10
11 rm -rf $name-$version
12
13 builddir=`pwd`
14 sourcedir=`pwd`
15
16 echo `pwd`
17
18 # Clean tmp directory.
19 rm -rf ./tmp
20
21 # Create directory structure for GBS Build
22 mkdir ./tmp
23 mkdir ./tmp/extlibs/
24 mkdir ./tmp/packaging
25 cp -R ./build_common $sourcedir/tmp
26 cp -R ./examples $sourcedir/tmp
27
28 # tinycbor is available as soft-link, so copying with 'dereference' option.
29 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
30 rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
31
32 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
33 cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
34 cp -R ./extlibs/gtest $sourcedir/tmp/extlibs
35 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
36 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
37 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
38 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
39 cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
40 cp -R ./resource $sourcedir/tmp
41 cp -R ./service $sourcedir/tmp
42 cp ./extra_options.scons $sourcedir/tmp
43 cp ./tools/tizen/*.spec ./tmp/packaging
44 cp ./tools/tizen/*.manifest ./tmp/packaging
45 cp ./SConstruct ./tmp
46 cp ./LICENSE.md ./tmp
47
48 # copy dependency RPMs and conf files for tizen build
49 cp ./tools/tizen/*.rpm ./tmp
50 cp ./tools/tizen/.gbs.conf ./tmp
51 cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
52 cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
53
54 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
55
56 cd $sourcedir/tmp
57
58 withtcp=0
59 withcloud=0
60 withproxy=0
61 withmq=OFF
62 rdmode=CLIENT
63 secured=0
64 for ARGUMENT_VALUE in $*
65 do
66    echo $ARGUMENT_VALUE
67    if [ "WITH_TCP" = $ARGUMENT_VALUE ];then
68        withtcp=1
69    fi
70
71    if [ "WITH_CLOUD" = $ARGUMENT_VALUE ];then
72        withcloud=1
73    fi
74
75    if [ "WITH_PROXY" = $ARGUMENT_VALUE ];then
76        withproxy=1
77    fi
78
79    if [ "WITH_MQ" = $ARGUMENT_VALUE ];then
80        withmq=PUB,SUB,BROKER
81    fi
82
83    if [ "RD_MODE" = $ARGUMENT_VALUE ];then
84        rdmode=CLIENT,SERVER
85    fi
86
87    if [ "SECURED" = $ARGUMENT_VALUE ];then
88        secured=1
89    fi
90 done
91
92 if [ $secured -eq 1 ];then
93   echo `pwd`
94   if [ -d ./extlibs/mbedtls/mbedtls ];then
95       cd ./extlibs/mbedtls/mbedtls
96       git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch
97       cd -
98       rm -rf ./extlibs/mbedtls/mbedtls/.git*
99
100   else
101       echo ""
102       echo "*********************************** Error: ****************************************"
103       echo "* Please download mbedtls using the following command:                            *"
104       echo "*     $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls  *"
105       echo "***********************************************************************************"
106       echo ""
107       exit
108   fi
109 fi
110
111 rm -rf ./extlibs/tinycbor/tinycbor/.git*
112
113 # Initialize Git repositoryㅣ
114 if [ ! -d .git ]; then
115    git init ./
116    git config user.email "you@example.com"
117    git config user.name "Your Name"
118    git add ./
119    git commit -m "Initial commit"
120 fi
121
122 echo "Calling core gbs build command"
123 gbscommand="gbs build -A armv7l --define 'WITH_TCP $withtcp' --define 'WITH_CLOUD $withcloud' --define 'WITH_PROXY $withproxy' --define 'WITH_MQ $withmq' --define 'RD_MODE $rdmode' --define 'SECURED $secured' -B ~/GBS-ROOT-OIC --include-all --repository ./"
124 echo $gbscommand
125 if eval $gbscommand; then
126     echo "Build is successful"
127 else
128     echo "Build failed!"
129     exit 1
130 fi
131
132
133 rm -rf tmp
134 cd $sourcedir
135 rm -rf $sourcedir/tmp
136
137 exit 0