From c93f7ed1dc2b9518580d8cb2c2be04da61015055 Mon Sep 17 00:00:00 2001 From: Gun Kim Date: Wed, 12 Dec 2012 16:31:16 +0900 Subject: [PATCH] [Title] added native-run [Type] [Module] [Priority] [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] Change-Id: I14e9bc3239f59d73d1f9e086528d5ae1a3cffdf6 --- org.tizen.cli/doc/install/native_bin/native-debug | 85 ++++++++---- .../native_bin/{native-pack => native-packaging} | 0 org.tizen.cli/doc/install/native_bin/native-run | 145 +++++++++++++++++++++ 3 files changed, 206 insertions(+), 24 deletions(-) rename org.tizen.cli/doc/install/native_bin/{native-pack => native-packaging} (100%) create mode 100755 org.tizen.cli/doc/install/native_bin/native-run diff --git a/org.tizen.cli/doc/install/native_bin/native-debug b/org.tizen.cli/doc/install/native_bin/native-debug index 8a9c54a..92ac4fc 100755 --- a/org.tizen.cli/doc/install/native_bin/native-debug +++ b/org.tizen.cli/doc/install/native_bin/native-debug @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -x SUBSTRING_START_POSITION=2 @@ -24,8 +24,45 @@ usage() { echo "Usage: $0 [options]" echo " -s, --serial \t\tdirects command to the USB device or emulator with" echo "\t\t\t\t\tthe given serial number." - echo " -a, --appid \t\t\tdebug this app on target." - echo " -b, --binary \t\tdebug this binary on target." + echo " -a, --appid \t\t\tdebugs the application on target." + echo " -b, --binary \t\tdebugs this binary on target." +} + +getBinaryFile() { + SDB_GET_BINARY_COMMAND="$SDB_COMMAND shell ls /opt/apps/$appid/bin/" + count=0 + extension=".exe" + extension_length=4 + result_list=`$SDB_GET_BINARY_COMMAND` + for i in ${result_list} + do + length=`expr match "$i" '.*[.]exe'` + start_pos=`expr $length - "$extension_length" + 1` + str=`expr substr "$i" "$start_pos" "$extension_length"` + if [ "$str" = "$extension" ] + then + BINARY=$i + if [ -z "$binary_list" ] + then + binary_list=$i + else + binary_list="$binary_list, $i" + + fi + count=`expr "$count" + 1` + fi + done + + if [ "$count" -eq "0" ] + then + echo "error: not found executable file of \"$appid\"." + exit 2; + elif [ "$count" -gt "1" ] + then + echo "error: more then one executable file of \"$appid\"." + echo "executable files: $binary_list" + exit 2; + fi } parse_param() { @@ -34,7 +71,7 @@ parse_param() { case "$1" in -h) - usage + usage; exit; ;; -s|--serial) @@ -61,7 +98,7 @@ parse_param() { usage exit 1; fi - binary=$2 + BINARY=$2 shift 2; ;; *) @@ -71,18 +108,6 @@ parse_param() { esac done - if [ -z "$appid" ] - then - usage - exit 1; - fi - - if [ -z "$binary" ] - then - usage - exit 1; - fi - devices=`sdb devices | wc -l` if [ "$devices" -lt 2 ] then @@ -98,17 +123,29 @@ parse_param() { exit 2; fi fi -} - -launch_gdbserver() { - target_install_path=/opt/apps/$appid/bin/$binary - gdbserver_command="/home/developer/sdk_tools/gdbserver/gdbserver :26102 $target_install_path" SDB_COMMAND="$SDB" if [ -n "$serial" ] then - SDB_COMMAND="$SDB_COMMAND -s $serial" + SDB_COMMAND="$SDB -s $serial" + fi + + if [ -z "$appid" ] + then + usage + exit 1; + fi + + if [ -z "$BINARY" ] + then + getBinaryFile fi +} + +launch_gdbserver() { + target_install_path=/opt/apps/$appid/bin/$BINARY + gdbserver_command="/home/developer/sdk_tools/gdbserver/gdbserver :26102 $target_install_path" + sdb_gdbserver_command="$SDB_COMMAND shell $gdbserver_command" $sdb_gdbserver_command 2> /dev/null & sleep 1 @@ -130,7 +167,7 @@ launch_gdb() { gdb="$TOOLS_HOME/i386-linux-gnueabi-gdb-7.2/bin/i386-linux-gnueabi-gdb" fi - $gdb $binary '--eval-command=target remote:7123' + $gdb $BINARY '--eval-command=target remote:7123' echo ""; } diff --git a/org.tizen.cli/doc/install/native_bin/native-pack b/org.tizen.cli/doc/install/native_bin/native-packaging similarity index 100% rename from org.tizen.cli/doc/install/native_bin/native-pack rename to org.tizen.cli/doc/install/native_bin/native-packaging diff --git a/org.tizen.cli/doc/install/native_bin/native-run b/org.tizen.cli/doc/install/native_bin/native-run new file mode 100755 index 0000000..7d18dcf --- /dev/null +++ b/org.tizen.cli/doc/install/native_bin/native-run @@ -0,0 +1,145 @@ +#!/bin/sh -x + +SUBSTRING_START_POSITION=2 + +SCRIPT="$0" +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +DIR_BIN=`dirname $SCRIPT` +TOOLS_HOME="$DIR_BIN/../.." +SDB="$TOOLS_HOME/sdb" +LAUNCH_APP="launch_app" + +usage() +{ + echo "Usage: $0 [options]" + echo " -s, --serial \t\tdirects command to the USB device or emulator with" + echo "\t\t\t\t\tthe given serial number." + echo " -a, --appid \t\t\tlaunches the application on target." + echo " -b, --binary \t\tlaunches this binary on target." +} + +getBinaryFile() { + SDB_GET_BINARY_COMMAND="$SDB_COMMAND shell ls /opt/apps/$appid/bin/" + count=0 + extension=".exe" + extension_length=4 + result_list=`$SDB_GET_BINARY_COMMAND` + for i in ${result_list} + do + length=`expr match "$i" '.*[.]exe'` + start_pos=`expr $length - "$extension_length" + 1` + str=`expr substr "$i" "$start_pos" "$extension_length"` + if [ "$str" != "$extension" ] + then + BINARY=$i + if [ -z "$binary_list" ] + then + binary_list=$i + else + binary_list="$binary_list, $i" + + fi + count=`expr "$count" + 1` + fi + done + + if [ "$count" -eq "0" ] + then + echo "error: not found executable file of \"$appid\"." + exit 2; + elif [ "$count" -gt "1" ] + then + echo "error: more then one executable file of \"$appid\"." + echo "executable files: $binary_list" + exit 2; + fi +} + +until [ -z "$1" ] +do + case "$1" + in + -h) + usage + exit; + ;; + -s|--serial) + if [ -z "$2" ] + then + usage + exit 1; + fi + serial=$2 + shift 2; + ;; + -a|--appid) + if [ -z "$2" ] + then + usage + exit 1; + fi + appid=$2 + shift 2; + ;; + -b|--binary) + if [ -z "$2" ] + then + usage + exit 1; + fi + BINARY=$2 + ;; + *) + usage + exit; + ;; + esac +done + +SDB_COMMAND="$SDB" +if [ -n "$serial" ] +then + SDB_COMMAND="$SDB -s $serial" +fi + +if [ -z "$appid" ] +then + usage + exit 1; +fi + +if [ -z "$BINARY" ] +then + getBinaryFile +fi + + +devices=`$SDB_COMMAND devices | wc -l` +if [ "$devices" -lt 2 ] +then + echo "error: device not found" + exit 2; +fi +if [ "$devices" -gt 2 ] +then + if [ -z "$serial" ] + then + echo "error: more than one device and emulator" + exit 2; + fi +fi + +command="$SDB_COMMAND shell $LAUNCH_APP $appid.$BINARY" + +$command + -- 2.7.4