Merge remote-tracking branch 'origin/master' into notification-service
[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 echo $1
14 export ES_SAMPLE=$1
15
16 builddir=`pwd`
17 sourcedir=`pwd`
18
19 echo `pwd`
20
21 # Clean tmp directory.
22 rm -rf ./tmp
23
24 # Create directory structure for GBS Build
25 mkdir ./tmp
26 mkdir ./tmp/extlibs/
27 mkdir ./tmp/packaging
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/gtest $sourcedir/tmp/extlibs
37 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
38 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
39 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
40 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
41 cp -R ./resource $sourcedir/tmp
42 cp -R ./service $sourcedir/tmp
43 cp ./extra_options.scons $sourcedir/tmp
44 cp ./tools/tizen/*.spec ./tmp/packaging
45 cp ./tools/tizen/*.manifest ./tmp/packaging
46 cp ./SConstruct ./tmp
47 cp ./LICENSE.md ./tmp
48
49 # copy dependency RPMs and conf files for tizen build
50 cp ./tools/tizen/*.rpm ./tmp
51 cp ./tools/tizen/.gbs.conf ./tmp
52 cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
53 cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
54
55 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
56
57 cd $sourcedir/tmp
58
59 echo `pwd`
60 rm -rf ./extlibs/tinycbor/tinycbor/.git*
61
62 # Initialize Git repository
63 if [ ! -d .git ]; then
64    git init ./
65    git config user.email "you@example.com"
66    git config user.name "Your Name"
67    git add ./
68    git commit -m "Initial commit"
69 fi
70
71 echo "Calling core gbs build command"
72 gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --repository ./"
73 echo $gbscommand
74 if eval $gbscommand; then
75    echo "Build is successful"
76 else
77    echo "Build failed!"
78    exit 1
79 fi
80
81 # Build EasySetup App. if ES_ON is entered on command prompt
82 if echo $ES_SAMPLE|grep -qi '^ES_ON$'; then
83     cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
84     echo `pwd`
85     echo "EasySetup Sample Build is enabled"
86
87     # Initialize Git repository for EnrolleeSample
88     if [ ! -d .git ]; then
89       git init ./
90       git config user.email "you@example.com"
91       git config user.name "Your Name"
92       git add ./
93       git commit -m "Initial commit"
94     fi
95     echo "Calling EasySetup Sample gbs build command"
96     gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --repository ./"
97     echo $gbscommand
98     if eval $gbscommand; then
99       echo "EasySetup Sample build is successful"
100     else
101       echo "EasySetup Sample build is failed."
102       exit 1
103     fi
104 else
105     echo "EasySetup Sample Build is not enabled"
106 fi
107
108 rm -rf tmp
109 cd $sourcedir
110 rm -rf $sourcedir/tmp
111
112 exit 0