[IOT-1230] Resolving tizen platform build issue with mbedtls library included
[platform/upstream/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 ./resource $sourcedir/tmp
40 cp -R ./service $sourcedir/tmp
41 cp ./extra_options.scons $sourcedir/tmp
42 cp ./tools/tizen/*.spec ./tmp/packaging
43 cp ./tools/tizen/*.manifest ./tmp/packaging
44 cp ./SConstruct ./tmp
45 cp ./LICENSE.md ./tmp
46
47 # copy dependency RPMs and conf files for tizen build
48 cp ./tools/tizen/*.rpm ./tmp
49 cp ./tools/tizen/.gbs.conf ./tmp
50 cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
51 cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
52
53 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
54
55 cd $sourcedir/tmp
56
57 echo `pwd`
58 if [ -d ./extlibs/mbedtls/mbedtls ];then
59     cd ./extlibs/mbedtls/mbedtls
60     git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch
61     cd -
62     rm -rf ./extlibs/mbedtls/mbedtls/.git*
63
64 else
65     echo ""
66     echo "*********************************** Error: ****************************************"
67     echo "* Please download mbedtls using the following command:                            *"
68     echo "*     $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls  *"
69     echo "***********************************************************************************"
70     echo ""
71     exit
72 fi
73 rm -rf ./extlibs/tinycbor/tinycbor/.git*
74
75
76 # Initialize Git repository
77 if [ ! -d .git ]; then
78    git init ./
79    git config user.email "you@example.com"
80    git config user.name "Your Name"
81    git add ./
82    git commit -m "Initial commit"
83 fi
84
85 withtcp=0
86 withcloud=0
87 if [ "WITH_TCP" = "$1" ] || [ "WITH_TCP" = "$2" ];then
88     withtcp=1
89 fi
90 if [ "WITH_CLOUD" = "$1" ] || [ "WITH_CLOUD" = "$2" ];then
91     withcloud=1
92 fi
93
94 echo "Calling core gbs build command"
95 gbscommand="gbs build -A armv7l --define 'WITH_TCP $withtcp' --define 'WITH_CLOUD $withcloud' -B ~/GBS-ROOT-OIC --include-all --repository ./"
96 echo $gbscommand
97 if eval $gbscommand; then
98     echo "Build is successful"
99 else
100     echo "Build failed!"
101     exit 1
102 fi
103
104
105 rm -rf tmp
106 cd $sourcedir
107 rm -rf $sourcedir/tmp
108
109 exit 0