1#!/usr/bin/bash
2
3###############################################################################
4#
5# Copyright (C) 2009-2013 Nintendo.  All rights reserved.
6#
7# These coded instructions, statements, and computer programs contain
8# proprietary information of Nintendo of America Inc. and/or Nintendo
9# Company Ltd., and are protected by Federal copyright law.  They may
10# not be disclosed to third parties or copied or duplicated in any form,
11# in whole or in part, without the prior written consent of Nintendo.
12#
13###############################################################################
14
15source $(dirname "$0")/xmain.sh
16#==============================
17#DEBUG RPX
18#This script runs an RPX under
19#debug mode
20#
21#VERSION 1.4
22#==============================
23
24displayHelp(){
25  FIL=$(basename "$0")
26  echo "Debug RPX Script
27Options (optional):
28	-b                 : RPX is a debug version (default NDEBUG)
29	-u                 : Title is on USB (default: PCFS)
30	-n                 : Title is on NAND (default: PCFS)
31	-r <path/filename> : location of RPX (not including .rpx)
32	--help
33	  -h
34	  --h
35	  -help            : Display help
36
37Options (last optional):
38	-a <args>          : arguments to run the RPX with
39
40Usage:
41$FIL [optionals] [-a ...]
42
43Example:
44#Using first RPX in current working directory (NDEBUG)
45$FIL
46
47#---or---
48#Specify parameters (args = anything past -a)
49$FIL -u -a -x 30 -y 20
50
51#---or---
52#Specify absolute or relative path to a DEBUG RPX
53$FIL -b -u -r \"\$CAFE_ROOT/system/bin/\$TOOLCHAIN/\$PLATFORM\"/demo/helloworld/NDEBUG/helloworld"
54
55  exit $1
56}
57
58initFlags
59#TITLE_PCFS=0 #debug via PCFS (default)
60
61#parse user input
62ARG=("$@")
63for((i=0;i<$#;++i));do
64  case "${ARG[i]}" in
65
66	#path to RPX
67	-r)if [ $((++i)) -ge $# ];then
68	  break
69	fi
70	FIL="${ARG[i]}";;
71
72	#RPX arguments
73	-a)ARG="${ARG[@]:$((++i))}"
74	break;;
75
76	#debug build of RPX
77	-b)FLG=$((FLG|DBG_BUILD));;
78	#debug title on USB
79	-u)FLG=$((FLG|TITLE_USB));;
80	#debug title on MLC
81	-n)FLG=$((FLG|TITLE_MLC));;
82
83	#display help and exit
84	-h|--h|-help|--help)
85	displayHelp 0;;
86  esac
87done
88if [ $((++i)) -ge $# ];then
89  unset ARG
90fi
91i=
92
93#verify user input
94getRPX
95
96#sync the session
97doSync
98
99#execute debug function
100runDBG
101