8d761f0ec840194ca51fedd12d8419557232b954
[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 gbsarch=${gbsarch:=armv7l}
11
12 echo $1
13 export TARGET_TRANSPORT=$1
14
15 echo $2
16 export SECURED=$2
17
18 echo $3
19 export BUILD_SAMPLE=$3
20
21 echo $4
22 export RELEASE=$4
23
24 echo $5
25 export LOGGING=$5
26
27 echo $6
28 export ROUTING=$6
29
30 echo $7
31 export WITH_TCP=$7
32
33 echo $8
34 export WITH_PROXY=$8
35
36 echo $9
37 export WITH_MQ=$9
38
39 echo $TARGET_TRANSPORT
40 echo $BUILD_SAMPLE
41 echo $WITH_MQ
42
43 rm -rf $name-$version
44
45 builddir=`pwd`
46 sourcedir=`pwd`
47
48 echo `pwd`
49
50 rm -rf ./tmp
51 mkdir ./tmp
52 mkdir ./tmp/extlibs/
53 mkdir ./tmp/packaging
54 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
55 cp -Rf ./extlibs/mbedtls $sourcedir/tmp/extlibs
56 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
57 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
58 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
59 cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
60 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
61 cp -R ./resource/csdk/stack/samples/tizen/build/packaging/*.spec $sourcedir/tmp/packaging
62 cp -R ./resource $sourcedir/tmp/
63 cp -R ./build_common/external_libs.scons $sourcedir/tmp/
64 mkdir -p $sourcedir/tmp/build_common/
65 cp -a ./build_common/*.scons $sourcedir/tmp/build_common/
66
67 # copy dependency RPMs and conf files for tizen build
68 cp ./tools/tizen/*.rpm $sourcedir/tmp
69 cp ./tools/tizen/*.rpm $sourcedir/tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
70 cp ./tools/tizen/.gbs.conf ./tmp
71 cp ./tools/tizen/.gbs.conf ./tmp/resource/csdk/stack/samples/tizen/SimpleClientServer
72
73 cd $sourcedir
74 cd ./resource/csdk/stack/samples/tizen/build/
75
76 cp -R ./* $sourcedir/tmp/
77 rm -f $sourcedir/tmp/SConscript
78 cp SConstruct $sourcedir/tmp/
79 cp scons/SConscript $sourcedir/tmp/scons/
80
81 mkdir -p $sourcedir/tmp/iotivityconfig
82 cd $sourcedir/build_common/
83 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
84 cp -R ./SConscript $sourcedir/tmp/
85
86 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
87
88 cd $sourcedir/tmp
89
90 echo `pwd`
91 # Prepare mbedTLS dependency
92 $SHELL ./extlibs/mbedtls/prep.sh
93
94 # Prepare TinyCBOR dependency
95 $SHELL ./extlibs/tinycbor/prep.sh
96
97 whoami
98 # Initialize Git repository
99 if [ ! -d .git ]; then
100    git init ./
101    git config user.email "you@example.com"
102    git config user.name "Your Name"
103    git add ./
104    git commit -m "Initial commit"
105 fi
106
107 gbsprofile=${gbsprofile:=profile.tizen}
108 gbscommand_prefix="gbs build -A ${gbsarch} -P ${gbsprofile} "
109 nproc=$(expr 1 + $(expr `nproc --ignore=1` / 2 ) )
110 gbscommand_prefix=${gbscommand_prefix}" --define '_smp_mflags -j${nproc}'"
111
112 echo "Calling core gbs build command"
113 gbscommand=${gbscommand_prefix}" -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' --define 'WITH_PROXY $8' --define 'WITH_MQ $9'"
114 echo $gbscommand
115 if eval $gbscommand; then
116    echo "Core build is successful"
117 else
118    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
119    cd $sourcedir
120    rm -rf $sourcedir/tmp
121    exit 1
122 fi
123
124 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
125    cd resource/csdk/stack/samples/tizen/SimpleClientServer
126    echo `pwd`
127    # Initialize Git repository
128    if [ ! -d .git ]; then
129       git init ./
130       git config user.email "you@example.com"
131       git config user.name "Your Name"
132       git add ./
133       git commit -m "Initial commit"
134    fi
135    echo "Calling sample gbs build command"
136    gbscommand=${gbscommand_prefix}" -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' --define 'WITH_PROXY $8' --define 'WITH_MQ $9'"
137    echo $gbscommand
138    if eval $gbscommand; then
139       echo "Sample build is successful"
140    else
141       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
142       exit 1
143    fi
144 else
145         echo "Sample build is not enabled"
146 fi
147
148 cd $sourcedir
149 rm -rf $sourcedir/tmp
150
151 exit 0