Merge branch 'upstream' into tizen
[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
11 echo $1
12 export TARGET_TRANSPORT=$1
13
14 echo $2
15 export SECURED=$2
16
17 echo $3
18 export BUILD_SAMPLE=$3
19
20 echo $4
21 export RELEASE=$4
22
23 echo $5
24 export LOGGING=$5
25
26 echo $6
27 export ROUTING=$6
28
29 echo $TARGET_TRANSPORT
30 echo $BUILD_SAMPLE
31
32 rm -rf $name-$version
33
34 builddir=`pwd`
35 sourcedir=`pwd`
36
37 echo `pwd`
38
39 rm -rf ./tmp
40 mkdir ./tmp
41 mkdir ./tmp/extlibs/
42 mkdir ./tmp/packaging
43 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
44 rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
45 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
46 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
47 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
48 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
49 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
50 cp -R ./resource/csdk/stack/samples/tizen/build/packaging/*.spec $sourcedir/tmp/packaging
51 cp -R ./resource $sourcedir/tmp/
52 cp -R ./build_common/external_libs.scons $sourcedir/tmp/
53
54 # copy dependency RPMs and conf files for tizen build
55 cp ./tools/tizen/*.rpm $sourcedir/tmp
56 cp ./tools/tizen/*.rpm $sourcedir/tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
57 cp ./tools/tizen/.gbs.conf ./tmp
58 cp ./tools/tizen/.gbs.conf ./tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
59
60 cd $sourcedir
61 cd ./resource/csdk/stack/samples/tizen/build/
62
63 cp -R ./* $sourcedir/tmp/
64 rm -f $sourcedir/tmp/SConscript
65 cp SConstruct $sourcedir/tmp/
66 cp scons/SConscript $sourcedir/tmp/scons/
67
68 mkdir -p $sourcedir/tmp/iotivityconfig
69 cd $sourcedir/build_common/
70 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
71 cp -R ./SConscript $sourcedir/tmp/
72
73 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
74
75 cd $sourcedir/tmp
76
77 echo `pwd`
78
79 whoami
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 echo "Calling core gbs build command"
90 gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6'"
91 echo $gbscommand
92 if eval $gbscommand; then
93    echo "Core build is successful"
94 else
95    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
96    cd $sourcedir
97    rm -rf $sourcedir/tmp
98    exit 1
99 fi
100
101 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
102    cd resource/csdk/stack/samples/tizen/SimpleClientServer
103    echo `pwd`
104    # Initialize Git repository
105    if [ ! -d .git ]; then
106       git init ./
107       git config user.email "you@example.com"
108       git config user.name "Your Name"
109       git add ./
110       git commit -m "Initial commit"
111    fi
112    echo "Calling sample gbs build command"
113    gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-RI-OIC --include-all --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'ROUTING $6'"
114    echo $gbscommand
115    if eval $gbscommand; then
116       echo "Sample build is successful"
117    else
118       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
119       exit 1
120    fi
121 else
122         echo "Sample build is not enabled"
123 fi
124
125 cd $sourcedir
126 rm -rf $sourcedir/tmp
127
128 exit 0