Imported Upstream version 1.0.1
[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 cp -R $cur_dir/* $sourcedir/tmp/con
46 cp -R $cur_dir/SConscript $sourcedir/tmp/con
47 cp -R $cur_dir/src/ip_adapter/SConscript $sourcedir/tmp/con/src/ip_adapter/
48 cp -R $cur_dir/src/bt_le_adapter/SConscript $sourcedir/tmp/con/src/bt_le_adapter/
49 cp -R $cur_dir/src/bt_edr_adapter/SConscript $sourcedir/tmp/con/src/bt_edr_adapter/
50 cp -R $cur_dir/common/SConscript $sourcedir/tmp/con/common/
51 cp -R $cur_dir/lib/libcoap-4.1.1/SConscript $sourcedir/tmp/con/lib/libcoap-4.1.1/
52 cp -R $cur_dir/samples/tizen/ $sourcedir/tmp/con/sample/
53 mkdir -p $sourcedir/tmp/con/sample/lib/tizen/ble/libs
54 cp -R $cur_dir/lib/tizen/ble/libs/* $sourcedir/tmp/con/sample/lib/tizen/ble/libs/
55 mkdir -p $sourcedir/tmp/con/sample/external/inc
56 cp -R $cur_dir/external/inc/* $sourcedir/tmp/con/sample/external/inc/
57 mkdir -p $sourcedir/tmp/con/extlibs/
58 cp -R ./extlibs/tinydtls/ $sourcedir/tmp/con/extlibs/
59 mkdir -p $sourcedir/tmp/con/c_common
60 cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
61
62 # copy dependency RPMs and conf files for tizen build
63 cp ./tools/tizen/*.rpm $sourcedir/tmp
64 cp ./tools/tizen/*.rpm $sourcedir/tmp/con/sample
65 cp ./tools/tizen/.gbs.conf ./tmp
66 cp ./tools/tizen/.gbs.conf ./tmp/con/sample
67
68 cd $sourcedir
69 cd $cur_dir/build/tizen
70 cp -R ./* $sourcedir/tmp/
71 rm -f $sourcedir/tmp/SConscript
72 cp SConstruct $sourcedir/tmp/
73 cp scons/SConscript $sourcedir/tmp/scons/
74
75 mkdir -p $sourcedir/tmp/iotivityconfig
76 cd $sourcedir/build_common/
77 cp -R ./iotivityconfig/* $sourcedir/tmp/iotivityconfig/
78 cp -R ./SConscript $sourcedir/tmp/
79
80 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp/
81
82 cd $sourcedir/tmp
83
84 echo `pwd`
85
86 whoami
87 # Initialize Git repository
88 if [ ! -d .git ]; then
89    git init ./
90    git config user.email "you@example.com"
91    git config user.name "Your Name"
92    git add ./
93    git commit -m "Initial commit"
94 fi
95
96 echo "Calling core gbs build command"
97 gbscommand="gbs build -A armv7l --include-all  --repository ./ --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --define 'WITH_TCP $6'"
98 echo $gbscommand
99 if eval $gbscommand; then
100    echo "Core build is successful"
101 else
102    echo "Core build failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
103    cd $sourcedir
104    rm -rf $sourcedir/tmp
105    exit 1
106 fi
107
108 if echo $BUILD_SAMPLE|grep -qi '^ON$'; then
109    cd con/sample
110    echo `pwd`
111    # Initialize Git repository
112    if [ ! -d .git ]; then
113       git init ./
114       git config user.email "you@example.com"
115       git config user.name "Your Name"
116       git add ./
117       git commit -m "Initial commit"
118    fi
119    echo "Calling sample gbs build command"
120    gbscommand="gbs build -A armv7l --include-all --define 'TARGET_TRANSPORT $1' --define 'SECURED $2' --define 'RELEASE $4' --define 'LOGGING $5' --repository ./"
121    echo $gbscommand
122    if eval $gbscommand; then
123       echo "Sample build is successful"
124    else
125       echo "Sample build is failed. Try 'find . -type f -exec dos2unix {} \;' in the 'connectivity/' folder"
126       exit 1
127    fi
128 else
129         echo "Sample build is not enabled"
130 fi
131
132 cd $sourcedir
133 rm -rf $sourcedir/tmp
134
135 exit 0