Fix a faulty logic in parsing a received query and in setting a URI string
[platform/upstream/iotivity.git] / service / easy-setup / sampleapp / enrollee / tizen-sdb / EnrolleeSample / build / tizen / gbsbuild.sh
1 #!/bin/sh
2
3 cur_dir="./service/easy-setup"
4 spec=`ls ./service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/packaging/*.spec`
5 version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
6
7 name=`echo $name|cut -d" " -f 1`
8 version=`echo $version|cut -d" " -f 1`
9
10 name=iotivity
11
12 rm -rf $name-$version
13
14 builddir=`pwd`
15 sourcedir=`pwd`
16
17 echo `pwd`
18
19 # Clean tmp directory.
20 rm -rf ./tmp
21
22 # Create directory structure for GBS Build
23 mkdir ./tmp
24 mkdir ./tmp/con/
25 mkdir ./tmp/extlibs/
26 mkdir ./tmp/packaging
27 mkdir ./tmp/logger
28 cp -R ./build_common $sourcedir/tmp
29 cp -R ./examples $sourcedir/tmp
30
31 # tinycbor is available as soft-link, so copying with 'dereference' option.
32 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
33 rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
34
35 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
36 cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
37 cp -R ./extlibs/gtest $sourcedir/tmp/extlibs
38 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
39 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
40 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
41 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
42 cp -R ./resource $sourcedir/tmp
43 cp -R ./service $sourcedir/tmp
44 cp ./extra_options.scons $sourcedir/tmp
45 cp ./tools/tizen/*.spec ./tmp/packaging
46 cp ./tools/tizen/*.manifest ./tmp/packaging
47 cp ./SConstruct ./tmp
48 cp ./LICENSE.md ./tmp
49
50 # copy dependency RPMs and conf files for tizen build
51 cp ./tools/tizen/*.rpm ./tmp
52 cp ./tools/tizen/.gbs.conf ./tmp
53 cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
54 cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
55
56 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
57
58 cd $sourcedir/tmp
59
60 echo `pwd`
61 if [ -d ./extlibs/mbedtls/mbedtls ];then
62     cd ./extlibs/mbedtls/mbedtls
63     git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch
64     cd -
65     rm -rf ./extlibs/mbedtls/mbedtls/.git*
66
67 else
68     echo ""
69     echo "*********************************** Error: ****************************************"
70     echo "* Please download mbedtls using the following command:                            *"
71     echo "*     $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls  *"
72     echo "***********************************************************************************"
73     echo ""
74     exit
75 fi
76 rm -rf ./extlibs/tinycbor/tinycbor/.git*
77
78
79 # Build IoTivity
80 # Initialize Git repository
81 if [ ! -d .git ]; then
82    git init ./
83    git config user.email "you@example.com"
84    git config user.name "Your Name"
85    git add ./
86    git commit -m "Initial commit"
87 fi
88
89 buildoption="--define 'TARGET_TRANSPORT '$1 --define 'SECURED '$2 --define 'ROUTING '$3 --define 'RELEASE '$4 --define 'LOGGING '$5 --define 'ES_TARGET_ENROLLEE '$6 --define 'WITH_TCP '$7 --define 'WITH_CLOUD '$8" 
90 echo "Calling core gbs build command"
91 gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC $buildoption --include-all --repository ./"
92 echo $gbscommand
93 if eval $gbscommand; then
94    echo "Core build is successful"
95 else
96    echo "Core build failed."
97    cd $sourcedir
98    rm -rf $sourcedir/tmp
99    exit 1
100 fi
101
102 # Build Enrollee Sample App
103 cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
104 echo `pwd`
105 # Initialize Git repository
106 if [ ! -d .git ]; then
107   git init ./
108   git config user.email "you@example.com"
109   git config user.name "Your Name"
110   git add ./
111   git commit -m "Initial commit"
112 fi
113 echo "Calling sample gbs build command"
114 gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC $buildoption --include-all --repository ./"
115 echo $gbscommand
116 if eval $gbscommand; then
117   echo "Sample build is successful"
118 else
119   echo "Sample build is failed."
120   exit 1
121 fi
122 rm -rf tmp
123 cd $sourcedir
124 rm -rf $sourcedir/tmp
125
126 exit 0