458e227468b0adba37cee9b4580cf064fbc07008
[platform/upstream/iotivity.git] / resource / csdk / connectivity / build / tizen / gbsbuild.sh
1 #!/bin/sh
2
3 cur_dir="./resource/csdk/connectivity/"
4
5 spec=`ls ./resource/csdk/connectivity/build/tizen/packaging/*.spec`
6 version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
7
8 name=`echo $name|cut -d" " -f 1`
9 version=`echo $version|cut -d" " -f 1`
10
11 name=oicca
12
13 echo $1
14 export TARGET_TRANSPORT=$1
15
16 echo $2
17 export SECURED=$2
18
19 echo $3
20 export BUILD_SAMPLE=$3
21
22 echo $4
23 export RELEASE=$4
24
25 echo $5
26 export LOGGING=$5
27
28 echo $6
29 export WITH_TCP=$6
30
31 echo $TARGET_TRANSPORT
32 echo $BUILD_SAMPLE
33 echo $WITH_TCP
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/con/
45 mkdir -p $sourcedir/tmp/con/extlibs/
46
47 cp -R $cur_dir/* $sourcedir/tmp/con
48 cp -R $cur_dir/SConscript $sourcedir/tmp/con
49 cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/
50 cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
51 cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
52 cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/
53 cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/
54 mkdir -p $sourcedir/tmp/con/sample/external/inc
55 cp -R $cur_dir/external/inc/* $sourcedir/tmp/con/sample/external/inc/
56
57 cp -R ./extlibs/tinydtls/ $sourcedir/tmp/con/extlibs/
58 cp -R ./extlibs/mbedtls/ $sourcedir/tmp/con/mbedtls/
59 cp -R ./extlibs/timer/ $sourcedir/tmp/con/extlibs/
60 cp -R ./extlibs/libcoap/ $sourcedir/tmp/con/extlibs/
61 mkdir -p $sourcedir/tmp/con/c_common
62 cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
63 cp -R ./resource/csdk/logger/include/* $sourcedir/tmp/con/common/inc/
64 mkdir ./tmp/con/logger/
65 cp -R ./resource/csdk/logger/* $sourcedir/tmp/con/logger
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/con/sample
70 cp ./tools/tizen/.gbs.conf ./tmp
71 cp ./tools/tizen/.gbs.conf ./tmp/con/sample
72
73 cd $sourcedir
74 cd $cur_dir/build/tizen
75 cp -R ./* $sourcedir/tmp/
76 rm -f $sourcedir/tmp/SConscript
77 cp SConstruct $sourcedir/tmp/
78 cp scons/SConscript $sourcedir/tmp/scons/
79
80 mkdir -p $sourcedir/tmp/iotivityconfig
81 cd $sourcedir/build_common/
82 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
83 cp -R ./SConscript $sourcedir/tmp/
84
85 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
86
87 cd $sourcedir/tmp
88
89 echo `pwd`
90 # Prepare mbedTLS dependency
91 $SHELL ./extlibs/mbedtls/prep.sh
92
93 whoami
94 # Initialize Git repository
95 if [ ! -d .git ]; then
96    git init ./
97    git config user.email "you@example.com"
98    git config user.name "Your Name"
99    git add ./
100    git commit -m "Initial commit"
101 fi
102
103 echo "Calling core gbs build command"
104 gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all  --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'WITH_TCP $6'"
105 echo $gbscommand
106 if eval $gbscommand; then
107    echo "Core build is successful"
108 else
109    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
110    cd $sourcedir
111    rm -rf $sourcedir/tmp
112    exit 1
113 fi
114
115 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
116    cd con/sample
117    echo `pwd`
118    # Initialize Git repository
119    if [ ! -d .git ]; then
120       git init ./
121       git config user.email "you@example.com"
122       git config user.name "Your Name"
123       git add ./
124       git commit -m "Initial commit"
125    fi
126    echo "Calling sample gbs build command"
127    gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --repository ./"
128    echo $gbscommand
129    if eval $gbscommand; then
130       echo "Sample build is successful"
131    else
132       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
133       exit 1
134    fi
135 else
136         echo "Sample build is not enabled"
137 fi
138
139 cd $sourcedir
140 rm -rf $sourcedir/tmp
141
142 exit 0