set label * when pushing a file
[framework/system/sdbd.git] / sdk_launch
1 #!/bin/bash
2
3 # Authors:
4 #      Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park <yoonki.park@samsung.com>
5 #
6 # Description: front hand of app launcher
7
8 APP_PATH_PREFIX=/opt/apps
9 SDK_TOOLS_PATH=/home/developer/sdk_tools
10
11 print_usage()
12 {
13     echo "usage: $0 -p <pkgid> -e <executable> -m <run|debug|da|oprofile> [-P <port>] [-attach <pid>] -t <gtest,gcov> [<args...>]"
14 }
15
16 first="true"
17
18 until [ -z "$1" ]; do
19     case "$1" in
20     -p)
21         if [ -z "$2" ]
22         then
23             print_usage
24             exit 1;
25         fi
26         pkgid=$2
27         shift 2;
28         ;;
29     -e)
30         if [ -z "$2" ]
31         then
32             print_usage
33             exit 1;
34         fi
35         exe=${2/%.exe/}
36         shift 2;
37         ;;
38     -m)
39         if [ "$2" != "run" ] && [ "$2" != "debug" ] && [ "$2" != "da" ] && [ "$2" != "oprofile" ]
40         then
41             print_usage
42             exit 1;
43         fi
44         mode=$2
45         shift 2;
46         ;;
47     -P)
48         if [ -z "$2" ]
49         then
50             print_usage
51             exit 1;
52         fi
53         port=$2
54         shift 2;
55         ;;
56     -attach)
57         if [ -z "$2" ]
58         then
59             print_usage
60             exit 1;
61         fi
62         attach_id=$2
63         shift 2;
64         ;;
65     -t)
66         if [ "$2" = "" ] || [ ${2:0:1} = "-" ]
67         then
68             shift 1;
69         else
70 # parse -t option
71         OLD_IFS=$IFS;IFS=,;
72         for type in $2;do
73             if [ "$type" = "gtest" ]
74             then
75                 COV_TEST_PREFIX="export LD_LIBRARY_PATH=%s/gtest/usr/lib && $COV_TEST_PREFIX"
76                 if [ "" != "$result_mode" ]
77                 then
78                     result_mode="$result_mode,UNIT_TEST"
79                 else
80                     launch_app_mode="__LAUNCH_APP_MODE__ SYNC"
81                     result_mode="UNIT_TEST"
82                 fi
83             fi
84             if [ "$type" = "gcov" ]
85             then
86                 COV_TEST_PREFIX="export GCOV_PREFIX=/tmp/%s/data && export GCOV_PREFIX_STRIP=0 && $COV_TEST_PREFIX"
87                 if [ "" != "$result_mode" ]
88                 then
89                     result_mode="$result_mode,CODE_COVERAGE"
90                 else
91                     launch_app_mode="__LAUNCH_APP_MODE__ SYNC"
92                     result_mode="CODE_COVERAGE"
93                 fi
94             fi
95         done;
96         IFS=$OLD_IFS
97
98         shift 2;
99         fi
100         ;;
101     *)
102         if [ "$first" = "true" ]
103         then
104             first="false"
105             args="__DLP_UNIT_TEST_ARG__ $1"
106         else
107             args="$args","$1"
108         fi
109         shift 1;
110     esac
111 done
112
113 if [ "$mode" = "debug" ]
114 then
115     if [ "" != "$attach_id" ]
116     #debug attach
117     then
118         cmd="$COV_TEST_PREFIX /home/developer/sdk_tools/gdbserver/gdbserver :$port --attach $attach_id"
119     #debug
120     else
121         if [ "" != "$result_mode" ]
122         then
123             result_mode="DEBUG,$result_mode"
124         else
125             result_mode="DEBUG"
126         fi
127         cmd="/usr/bin/launch_app $pkgid.$exe __AUL_SDK__ $result_mode __DLP_DEBUG_ARG__ :$port $launch_app_mode $args"
128 #       cmd="$COV_TEST_PREFIX /home/developer/sdk_tools/gdbserver/gdbserver :$port /opt/apps/$pkgid/bin/$exe"
129     fi
130 else
131     if [ "$mode" = "run" ]
132     then
133         if [ "" != "$result_mode" ]
134         then
135             cmd="/usr/bin/launch_app $pkgid.$exe __AUL_SDK__ $result_mode $launch_app_mode $args"
136         else
137             cmd="/usr/bin/launch_app $pkgid.$exe"
138         fi
139     else
140         if [ "$mode" = "da" ]
141         then
142             if [ "" != "$result_mode" ]
143             then
144                 result_mode="DYNAMIC_ANALYSIS,$result_mode"
145             else
146                 result_mode="DYNAMIC_ANALYSIS"
147             fi
148         fi
149         if [ "$mode" = "oprofile" ]
150         then
151             if [ "" == "$result_mode" ]
152             then
153                 result_mode="OPROFILE"
154             fi
155         fi
156         cmd="/usr/bin/launch_app $pkgid.$exe __AUL_SDK__ $result_mode"
157     fi
158 fi
159
160 # execute command
161 $cmd $args