[IOT-3106] Memory leak when converting PEM to DER
[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 gbsarch=${gbsarch:=armv7l}
57 gbsprofile=${gbsprofile:=profile.tizen}
58 gbscommand="gbs build -A ${gbsarch} -P ${gbsprofile}"
59 nproc=$(expr 1 + $(expr `nproc --ignore=1` / 2 ) )
60 gbscommand=$gbscommand" --define '_smp_mflags -j$nproc'"
61
62 for ARGUMENT_VALUE in $*
63 do
64    echo $ARGUMENT_VALUE
65    if [[ "$ARGUMENT_VALUE" = *"="* ]]; then
66       optionname=$(echo $ARGUMENT_VALUE | cut -f1 -d=)
67       optionvalue=$(echo $ARGUMENT_VALUE | cut -f2 -d=)
68       echo -- "# $optionname $optionvalue"
69       gbscommand=${gbscommand}" --define '$optionname $optionvalue'"
70
71       if [ "SECURED" = "$optionname" ]; then
72          secured=$optionvalue
73       fi
74    else
75       echo "'$ARGUMENT_VALUE' does not contain '='";
76    fi
77 done
78
79 gbscommand="${gbscommand} -B ~/GBS-ROOT-OIC --include-all --repository ./"
80 pwd
81
82 # Prepare mbedTLS dependency (also for unsecured as used by connectivity)
83 $SHELL ./extlibs/mbedtls/prep.sh
84
85 # Prepare TinyCBOR dependency
86 $SHELL ./extlibs/tinycbor/prep.sh
87
88 # Remove modules history for gbs export (Applies to tinycbor, mbedtls...)
89 rm -rf ./extlibs/*/*/.git
90
91 # Initialize Git repository„Ö£
92 if [ ! -d .git ]; then
93    git init ./
94    git config user.email "you@example.com"
95    git config user.name "Your Name"
96    git add ./
97    git commit -m "Initial commit"
98 fi
99
100 echo "Calling core gbs build command"
101 echo $gbscommand
102 if eval $gbscommand; then
103     echo "Build is successful"
104 else
105     echo "Build failed!"
106     exit 1
107 fi
108
109
110 rm -rf tmp
111 cd $sourcedir
112 rm -rf $sourcedir/tmp
113
114 exit 0