[IOT-2424] Fixed non-UUID subject rowner.
[iotivity.git] / gbsbuild.sh
1 #!/bin/bash -e
2
3 spec=`ls tools/tizen/*.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=iotivity
10
11 rm -rf $name-$version
12
13 builddir=`pwd`
14 sourcedir=`pwd`
15
16 echo `pwd`
17
18 # Clean tmp directory.
19 rm -rf ./tmp
20
21 # Create directory structure for GBS Build
22 mkdir ./tmp
23 mkdir ./tmp/extlibs/
24 mkdir ./tmp/packaging
25 cp -R ./build_common $sourcedir/tmp
26 cp -R ./examples $sourcedir/tmp
27
28 # tinycbor is available as soft-link, so copying with 'dereference' option.
29 cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
30
31 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
32 cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
33 cp -R ./extlibs/gtest $sourcedir/tmp/extlibs
34 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
35 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
36 cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
37 cp -R ./resource $sourcedir/tmp
38 cp -R ./service $sourcedir/tmp
39 cp ./extra_options.scons $sourcedir/tmp
40 cp ./tools/tizen/*.spec ./tmp/packaging
41 cp ./tools/tizen/*.manifest ./tmp/packaging
42 cp ./SConstruct ./tmp
43 cp ./LICENSE.md ./tmp
44
45 # copy dependency RPMs and conf files for tizen build
46 cp ./tools/tizen/*.rpm ./tmp
47 cp ./tools/tizen/.gbs.conf ./tmp
48 cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
49 cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
50
51 cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
52
53 cd $sourcedir/tmp
54
55 secured=1
56 gbscommand="gbs build -A armv7l "
57 nproc=$(expr 1 + $(expr `nproc --ignore=1` / 2 ) )
58 gbscommand=$gbscommand" --define '_smp_mflags -j$nproc'"
59
60 for ARGUMENT_VALUE in $*
61 do
62    echo $ARGUMENT_VALUE
63    if [[ "$ARGUMENT_VALUE" = *"="* ]]; then
64       optionname=$(echo $ARGUMENT_VALUE | cut -f1 -d=)
65       optionvalue=$(echo $ARGUMENT_VALUE | cut -f2 -d=)
66       echo -- "# $optionname $optionvalue"
67       gbscommand=${gbscommand}" --define '$optionname $optionvalue'"
68
69       if [ "SECURED" = "$optionname" ]; then
70          secured=$optionvalue
71       fi
72    else
73       echo "'$ARGUMENT_VALUE' does not contain '='";
74    fi
75 done
76
77 gbscommand="${gbscommand} -B ~/GBS-ROOT-OIC --include-all --repository ./"
78 pwd
79
80 # Prepare mbedTLS dependency (also for unsecured as used by connectivity)
81 $SHELL ./extlibs/mbedtls/prep.sh
82
83 # Prepare TinyCBOR dependency
84 $SHELL ./extlibs/tinycbor/prep.sh
85
86 # Remove modules history for gbs export (Applies to tinycbor, mbedtls...)
87 rm -rf ./extlibs/*/*/.git
88
89 # Initialize Git repository„Ö£
90 if [ ! -d .git ]; then
91    git init ./
92    git config user.email "you@example.com"
93    git config user.name "Your Name"
94    git add ./
95    git commit -m "Initial commit"
96 fi
97
98 echo "Calling core gbs build command"
99 echo $gbscommand
100 if eval $gbscommand; then
101     echo "Build is successful"
102 else
103     echo "Build failed!"
104     exit 1
105 fi
106
107
108 rm -rf tmp
109 cd $sourcedir
110 rm -rf $sourcedir/tmp
111
112 exit 0