Merge "Merge branch 'master' into notification-service" into notification-service
[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 $7
30 export WITH_TCP=$7
31
32 echo $TARGET_TRANSPORT
33 echo $BUILD_SAMPLE
34
35 rm -rf $name-$version
36
37 builddir=`pwd`
38 sourcedir=`pwd`
39
40 echo `pwd`
41
42 rm -rf ./tmp
43 mkdir ./tmp
44 mkdir ./tmp/extlibs/
45 mkdir ./tmp/packaging
46 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
47 rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
48 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
49 cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
50 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
51 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
52 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
53 cp -R ./resource/csdk/stack/samples/tizen/build/packaging/*.spec $sourcedir/tmp/packaging
54 cp -R ./resource $sourcedir/tmp/
55 cp -R ./build_common/external_libs.scons $sourcedir/tmp/
56 mkdir -p $sourcedir/tmp/build_common/
57 cp -a ./build_common/*.scons $sourcedir/tmp/build_common/
58
59 # copy dependency RPMs and conf files for tizen build
60 cp ./tools/tizen/*.rpm $sourcedir/tmp
61 cp ./tools/tizen/*.rpm $sourcedir/tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
62 cp ./tools/tizen/.gbs.conf ./tmp
63 cp ./tools/tizen/.gbs.conf ./tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
64
65 cd $sourcedir
66 cd ./resource/csdk/stack/samples/tizen/build/
67
68 cp -R ./* $sourcedir/tmp/
69 rm -f $sourcedir/tmp/SConscript
70 cp SConstruct $sourcedir/tmp/
71 cp scons/SConscript $sourcedir/tmp/scons/
72
73 mkdir -p $sourcedir/tmp/iotivityconfig
74 cd $sourcedir/build_common/
75 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
76 cp -R ./SConscript $sourcedir/tmp/
77
78 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
79
80 cd $sourcedir/tmp
81
82 echo `pwd`
83
84 whoami
85 # Initialize Git repository
86 if [ ! -d .git ]; then
87    git init ./
88    git config user.email "you@example.com"
89    git config user.name "Your Name"
90    git add ./
91    git commit -m "Initial commit"
92 fi
93
94 echo "Calling core gbs build command"
95 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' --define 'WITH_TCP $7'"
96 echo $gbscommand
97 if eval $gbscommand; then
98    echo "Core build is successful"
99 else
100    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
101    cd $sourcedir
102    rm -rf $sourcedir/tmp
103    exit 1
104 fi
105
106 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
107    cd resource/csdk/stack/samples/tizen/SimpleClientServer
108    echo `pwd`
109    # Initialize Git repository
110    if [ ! -d .git ]; then
111       git init ./
112       git config user.email "you@example.com"
113       git config user.name "Your Name"
114       git add ./
115       git commit -m "Initial commit"
116    fi
117    echo "Calling sample gbs build command"
118    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' --define 'WITH_TCP $7'"
119    echo $gbscommand
120    if eval $gbscommand; then
121       echo "Sample build is successful"
122    else
123       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
124       exit 1
125    fi
126 else
127         echo "Sample build is not enabled"
128 fi
129
130 cd $sourcedir
131 rm -rf $sourcedir/tmp
132
133 exit 0