Factor out common bits of build_mobile and build_tv scripts
authorArnaud Renevier <a.renevier@samsung.com>
Mon, 23 Feb 2015 20:48:47 +0000 (12:48 -0800)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Both scripts were almost identical, except in the values
set to TIZEN_VERSION and PROFILE_FLAG variable.

To avoid such duplication, patch factors out the common bits
into a function in common.sh named setupAndExecuteTargetBuild.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9215
Reviewed by: Antonio Gomes, Piotr Tworek

Change-Id: I2e36fc5c950d1af2d549838fa7d7246790498f53
Signed-off-by: Arnaud Renevier <a.renevier@samsung.com>
tizen_src/build/build_emulator.sh
tizen_src/build/build_mobile.sh
tizen_src/build/build_tv.sh
tizen_src/build/common.sh [changed mode: 0644->0755]

index 46c30e6..066bd41 100755 (executable)
@@ -3,16 +3,4 @@
 # source common functions and vars
 . `dirname $0`/common.sh
 
-# "|| :" means "or always succeeding built-in command"
-PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :)
-
-if [ "$PROFILE_NAME" == "" ]; then
-  PROFILE_NAME=tizen_emulator_v2.4
-  PROFILE_FLAG="-P $PROFILE_NAME"
-fi
-
-if [ "$USE_GLOBAL_GBS_CONF" == "" ]; then
-  CONF_FLAG="--conf ${SCRIPTDIR}/gbs.conf"
-fi
-
-gbs $CONF_FLAG build $PROFILE_FLAG -A i586 --incremental "$@"
+setupAndExecuteTargetBuild emulator "$@"
index ba1833d..b1b85d4 100755 (executable)
@@ -1,18 +1,5 @@
 #!/bin/bash
 
-# source common functions and vars
 . `dirname $0`/common.sh
 
-# "|| :" means "or always succeeding built-in command"
-PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :)
-
-if [ "$PROFILE_NAME" == "" ]; then
-  PROFILE_NAME=tizenmb_v2.4
-  PROFILE_FLAG="-P $PROFILE_NAME"
-fi
-
-if [ "$USE_GLOBAL_GBS_CONF" == "" ]; then
-  CONF_FLAG="--conf ${SCRIPTDIR}/gbs.conf"
-fi
-
-gbs $CONF_FLAG build $PROFILE_FLAG -A armv7l --incremental "$@"
+setupAndExecuteTargetBuild mobile "$@"
index f4f75b2..ea8e7b0 100755 (executable)
@@ -1,28 +1,10 @@
 #!/bin/bash
 
-# source common functions and vars
 . `dirname $0`/common.sh
 
-# "|| :" means "or always succeeding built-in command"
-PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :)
-
-ARCH="armv7l"
 EXTRA_PACK_OPTS="--extra-packs python-base-x86-arm,python-x86-arm,python-xml-x86-arm"
-if [ "${PROFILE_NAME:0:9}" == "tztv_v3.0" ]; then
-  EXTRA_PACK_OPTS=""
-else
-  PROFILE_NAME="tztv_v2.2.1_prehawk"
-fi
-
-if [ "$PROFILE_NAME" == "tztv_v3.0_emulator" ]; then
-    ARCH="i586"
-fi
-
-PROFILE_FLAG="-P $PROFILE_NAME"
-
-if [ "$USE_GLOBAL_GBS_CONF" == "" ]; then
-  CONF_FLAG="--conf ${SCRIPTDIR}/gbs.conf"
+if [ "$PROFILE_NAME" == "tztv_v3.0" ]; then
+   EXTRA_PACK_OPTS=""
 fi
 
-gbs $CONF_FLAG build $PROFILE_FLAG -A "${ARCH}" --incremental \
-    ${EXTRA_PACK_OPTS} "$@"
+setupAndExecuteTargetBuild tv "$@" $EXTRA_PACK_OPTS
old mode 100644 (file)
new mode 100755 (executable)
index c72f2f4..e6de375
@@ -158,3 +158,41 @@ function findElementInArray() {
   done
   return 1;
 }
+
+function setupAndExecuteTargetBuild() {
+
+  local platform="$1"
+  shift
+
+  local PROFILE_NAME
+  local DEFAULT_PROFILE_NAME
+  local ARCHITECTURE
+  local CONF_FLAG
+  local -a ARGS
+
+  # "|| :" means "or always succeeding built-in command"
+  PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :)
+
+  if [[ $platform == "mobile" ]]; then
+    DEFAULT_PROFILE_NAME=tizenmb_v2.4
+    ARCHITECTURE=armv7l
+  elif [[ $platform == "tv" ]]; then
+    DEFAULT_PROFILE_NAME=tztv_v2.2.1_prehawk
+    ARCHITECTURE=armv7l
+  elif [[ $platform == "emulator" ]]; then
+    DEFAULT_PROFILE_NAME=tizen_emulator_v2.4
+    ARCHITECTURE=i586
+  fi
+
+  if [ "$PROFILE_NAME" == "" ]; then
+    PROFILE_NAME=$DEFAULT_PROFILE_NAME
+  fi
+
+  PROFILE_FLAG="-P $PROFILE_NAME"
+
+  if [ "$USE_GLOBAL_GBS_CONF" == "" ]; then
+    CONF_FLAG="--conf ${SCRIPTDIR}/gbs.conf"
+  fi
+
+  gbs $CONF_FLAG build $PROFILE_FLAG -A $ARCHITECTURE --incremental "${@}"
+}