Update Snapshot(2018-12-12)
[platform/upstream/iotivity.git] / gbsbuild.sh
index aedbd1e..4872ca4 100755 (executable)
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/bash -e
 
-spec=`ls tools/tizen/*.spec`
+spec=`ls tools/tizen/iotivity.spec`
 version=`rpm --query --queryformat '%{version}\n' --specfile $spec`
 
 name=`echo $name|cut -d" " -f 1`
@@ -10,9 +10,6 @@ name=iotivity
 
 rm -rf $name-$version
 
-echo $1
-export ES_SAMPLE=$1
-
 builddir=`pwd`
 sourcedir=`pwd`
 
@@ -33,15 +30,16 @@ cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
 rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
 
 cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
+cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
 cp -R ./extlibs/gtest $sourcedir/tmp/extlibs
-cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
 cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
 cp -R ./extlibs/timer $sourcedir/tmp/extlibs
 cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
+cp -R ./extlibs/libcoap $sourcedir/tmp/extlibs
 cp -R ./resource $sourcedir/tmp
 cp -R ./service $sourcedir/tmp
 cp ./extra_options.scons $sourcedir/tmp
-cp ./tools/tizen/*.spec ./tmp/packaging
+cp ./tools/tizen/iotivity.spec ./tmp/packaging
 cp ./tools/tizen/*.manifest ./tmp/packaging
 cp ./SConstruct ./tmp
 cp ./LICENSE.md ./tmp
@@ -56,10 +54,38 @@ cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
 
 cd $sourcedir/tmp
 
-echo `pwd`
-rm -rf ./extlibs/tinycbor/tinycbor/.git*
+secured=1
+gbscommand="gbs build -A armv7l "
+
+for ARGUMENT_VALUE in $*
+do
+   echo $ARGUMENT_VALUE
+   if [[ "$ARGUMENT_VALUE" = *"="* ]]; then
+      optionname=$(echo $ARGUMENT_VALUE | cut -f1 -d=)
+      optionvalue=$(echo $ARGUMENT_VALUE | cut -f2 -d=)
+      echo -- "# $optionname $optionvalue"
+      gbscommand=${gbscommand}" --define '$optionname $optionvalue'"
+
+      if [ "SECURED" = "$optionname" ]; then
+         secured=$optionvalue
+      fi
+   else
+      echo "'$ARGUMENT_VALUE' does not contain '='";
+   fi
+done
+
+gbscommand="${gbscommand} -B ~/GBS-ROOT-OIC --include-all --repository ./"
+
+if [ $secured -eq 1 ];then
+  echo `pwd`
+  # Prepare mbedTLS dependency
+  $SHELL ./extlibs/mbedtls/prep.sh
+fi
 
-# Initialize Git repository
+# Prepare TinyCBOR dependency
+$SHELL ./extlibs/tinycbor/prep.sh
+
+# Initialize Git repositoryㅣ
 if [ ! -d .git ]; then
    git init ./
    git config user.email "you@example.com"
@@ -69,41 +95,14 @@ if [ ! -d .git ]; then
 fi
 
 echo "Calling core gbs build command"
-gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --repository ./"
 echo $gbscommand
 if eval $gbscommand; then
-   echo "Build is successful"
+    echo "Build is successful"
 else
-   echo "Build failed!"
-   exit 1
+    echo "Build failed!"
+    exit 1
 fi
 
-# Build EasySetup App. if ES_ON is entered on command prompt
-if echo $ES_SAMPLE|grep -qi '^ES_ON$'; then
-    cd service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
-    echo `pwd`
-    echo "EasySetup Sample Build is enabled"
-
-    # Initialize Git repository for EnrolleeSample
-    if [ ! -d .git ]; then
-      git init ./
-      git config user.email "you@example.com"
-      git config user.name "Your Name"
-      git add ./
-      git commit -m "Initial commit"
-    fi
-    echo "Calling EasySetup Sample gbs build command"
-    gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC --include-all --repository ./"
-    echo $gbscommand
-    if eval $gbscommand; then
-      echo "EasySetup Sample build is successful"
-    else
-      echo "EasySetup Sample build is failed."
-      exit 1
-    fi
-else
-    echo "EasySetup Sample Build is not enabled"
-fi
 
 rm -rf tmp
 cd $sourcedir