-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathksim.in
executable file
·128 lines (118 loc) · 2.49 KB
/
ksim.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# -*- mode: sh -*-
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
function show_help() {
cat <<EOF
Usage: ksim [OPTION]... [--] COMMAND ARGUMENTS
Run COMMAND with ARGUMENTS and under the ksim simulator.
-o, --output=FILE Output ksim messages to FILE.
-f, --framebuffer[=FILE] Output render target 0 to FILE as png.
--trace[=TAGS] Enable tracing for the given message tags.
Valid tags are 'debug', 'spam', 'warn', 'gem',
'cs', 'vf', 'vs', 'ps', 'eu', 'stub', 'all'.
Default value is 'stub,warn'. With no argument,
turn on all tags.
--breakpoint[=TAGS] Trigger a breakpoint on the given message tags.
--help Display this help message and exit.
EOF
exit 0
}
args=
device=0
while true; do
case "$1" in
-q)
args="${args}quiet;"
shift
;;
-o)
args="${args}file=$2;"
shift 2
;;
-o*)
args="${args}file=${1##-o};"
shift
;;
--output=*)
args="${args}file=${1##--output=};"
shift
;;
-f)
case "$2" in
-*)
args="${args}framebuffer;"
shift 1
;;
*)
args="${args}framebuffer=$2;"
shift 2
;;
esac
;;
-f*)
args="${args}framebuffer=${1##-f};"
shift
;;
--framebuffer=*)
args="${args}framebuffer=${1##--framebuffer=};"
shift
;;
--framebuffer)
args="${args}framebuffer;"
shift
;;
-t)
case "$2" in
-*)
args="${args}trace;"
shift 1
;;
*)
args="${args}trace=$2;"
shift 2
;;
esac
;;
-t*)
args="${args}trace=${1##-t};"
shift
;;
--trace=*)
args="${args}trace=${1##--trace=};"
shift
;;
--trace)
args="${args}trace=all;"
shift
;;
--breakpoint=*)
args="${args}breakpoint=${1##--breakpoint=};"
shift
;;
--stub=*)
ksim_stub_path=${1##--stub=};
shift
;;
--help)
show_help
;;
--)
shift
break
;;
-*)
echo "ksim: invalid option: $1"
echo
show_help
;;
*)
break
;;
esac
done
[ -z $1 ] && show_help
LD_PRELOAD=${ksim_stub_path:-${libdir}/ksim-stub.so}${LD_PPRELOAD:+:${LD_PRELOAD}} \
KSIM_ARGS="$args" \
exec -- "$@"