15a5b21d69b55e0c1e0765e5371ffe2738403f90
[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 $TARGET_TRANSPORT
29 echo $BUILD_SAMPLE
30
31 rm -rf $name-$version
32
33 builddir=`pwd`
34 sourcedir=`pwd`
35
36 echo `pwd`
37
38 mkdir ./tmp
39 mkdir ./tmp/con/
40 cp -R $cur_dir/* $sourcedir/tmp/con
41 cp -R $cur_dir/SConscript $sourcedir/tmp/con
42 cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/
43 cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
44 cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
45 cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/
46 cp -R $cur_dir/lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/
47 cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/
48 mkdir -p $sourcedir/tmp/con/sample/lib/tizen/ble/libs
49 cp -R $cur_dir/lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/
50 mkdir -p $sourcedir/tmp/con/sample/external/inc
51 cp -R $cur_dir/external/inc/* $sourcedir/tmp/con/sample/external/inc/
52 mkdir -p $sourcedir/tmp/con/extlibs/
53 cp -R ./extlibs/tinydtls/ $sourcedir/tmp/con/extlibs/
54 mkdir -p $sourcedir/tmp/con/c_common
55 cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
56
57 # copy dependency RPMs and conf files for tizen build
58 cp ./tools/tizen/*.rpm $sourcedir/tmp
59 cp ./tools/tizen/*.rpm $sourcedir/tmp/con/sample
60 cp ./tools/tizen/.gbs.conf ./tmp
61 cp ./tools/tizen/.gbs.conf ./tmp/con/sample
62
63 cd $sourcedir
64 cd $cur_dir/build/tizen
65 cp -R ./* $sourcedir/tmp/
66 rm -f $sourcedir/tmp/SConscript
67 cp SConstruct $sourcedir/tmp/
68 cp scons/SConscript $sourcedir/tmp/scons/
69
70 mkdir -p $sourcedir/tmp/iotivityconfig
71 cd $sourcedir/build_common/
72 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
73 cp -R ./SConscript $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 --include-all  --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5'"
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 con/sample
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 --include-all --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --repository ./"
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