forked from koreader/koreader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kodev
executable file
·760 lines (668 loc) · 21 KB
/
kodev
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
#!/usr/bin/env bash
set -eo pipefail
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
echo "incompatible bash version: ${BASH_VERSION}, need >=4.0"
exit 1
fi
# shellcheck disable=2155
declare -r CURDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
unset ANDROID_ARCH CMD HELP KODEBUG TARGET NO_BUILD VERBOSE
# Helpers. {{{
# shellcheck disable=2034
declare -r ANSI_BLUE='\33[34;1m'
# shellcheck disable=2034
declare -r ANSI_RED='\33[31;1m'
declare -r ANSI_RESET='\33[0m'
opt_dry_run=0
opt_timings=0
function info() {
local color=ANSI_BLUE
if [[ "$1" = -c* ]]; then
color="ANSI_${1#-c}"
shift
fi
if [[ -t 2 ]]; then
printf '%b%s%b\n' "${!color}" "$*" "${ANSI_RESET}" 1>&2
else
printf '%s\n' "$*" 1>&2
fi
}
function err() {
info -cRED "$@"
}
function die() {
local code=$?
if [[ $# -ne 0 ]]; then
code="$1"
shift
fi
if [[ $# -ne 0 ]]; then
err "$@"
fi
exit "${code}"
}
function print_quoted() {
if [[ $# -ne 0 ]]; then
printf '%q' "$1"
shift
fi
if [[ $# -ne 0 ]]; then
printf ' %q' "$@"
fi
}
function run() {
info "$(print_quoted "$@")"
if [[ ${opt_dry_run} -ne 0 ]]; then
return
fi
local cmd=("$@")
local code=0
if [[ ${opt_timings} -ne 0 ]]; then
time "${cmd[@]}" || code=$?
else
"${cmd[@]}" || code=$?
fi
return ${code}
}
function run_make() {
local cmd=(make)
if [[ ${opt_dry_run} -ne 0 ]]; then
cmd+=(-n)
fi
if [[ "${CURDIR}" != "${PWD}" ]]; then
cmd+=(-C "${CURDIR}")
fi
if [[ "${TARGET}" == 'android' ]]; then
cmd+=("ANDROID_ARCH=${ANDROID_ARCH}")
fi
for param in TARGET KODEBUG VERBOSE; do
cmd+=("${param}=${!param}")
done
cmd+=("$@")
opt_dry_run=0 run "${cmd[@]}"
}
is_system() {
if ! case "$1" in
Linux) [[ "${OSTYPE}" = linux* ]] ;;
macOS) [[ "${OSTYPE}" = darwin* ]] ;;
Windows) [[ "${OSTYPE}" == 'cygwin' || "${OSTYPE}" == 'msys' ]] ;;
*) false ;;
esac then
die 1 "You need a $1 system to build this package"
fi
}
check_submodules() {
# NOTE: can't use a pipe, or the pipeline may fail
# due to `git submodule status` returning an error
# on `grep -q …` early exit (broken pipe).
if grep -qE '^-' <<<"$(git submodule status)"; then
TARGET='' run_make fetchthirdparty
fi
}
show_help() {
local help="${HELP}"
help="${help#"${help%%[![:space:]]*}"}"
help="${help%"${help##*[![:space:]]}"}"
printf '\n%s\n\n' "${help}"
}
# }}}
# Target setup. {{{.
declare -r TARGETS_HELP_MSG="\
TARGET:
android-arm
android-arm64
android-x86
android-x86_64
appimage
cervantes
emulator Default if no TARGET is given
kindle Compatible with all Kindle models >= Kindle4
kindlehf Compatible with all Kindles with FW >= 5.16.3
kindlepw2 With compiler optimizations for Kindle models >= Paperwhite 2
kindle-legacy Needed only for Kindle2/3/DXG
kobo
kobov4 Compatible with Mk.7+ Kobo devices on FW 4.x
kobov5 Compatible with all Kobo & Tolino devices on FW 5.x
linux
macos MacOS app bundle
pocketbook
remarkable
sony-prstux
ubuntu-touch
win32
"
# shellcheck disable=2155
declare -r RELEASE_TARGETS_HELP_MSG="$(sed -e '/^ \(emulator\|win32\)/d' <<<"${TARGETS_HELP_MSG}")"
function setup_target() {
TARGET="$1"
shift 1
local valid=1
case "${TARGET}" in
# Emulator & native targets.
'' | emulator)
if [[ "${CMD}" == 'release' ]]; then
valid=0
fi
TARGET=''
;;
appimage | linux) is_system Linux ;;
macos) is_system macOS ;;
win32) is_system Windows ;;
# Devices.
android-arm | android-arm64 | android-x86 | android-x86_64)
ANDROID_ARCH="${TARGET#android-}"
TARGET='android'
;;
cervantes) ;;
kindle | kindlehf | kindlepw2 | kindle-legacy) ;;
kobo | kobov4 | kobov5) ;;
pocketbook) ;;
remarkable) ;;
sony-prstux) ;;
ubuntu-touch) ;;
# Invalid.
*)
valid=0
;;
esac
if [[ "${valid}" -eq 0 ]]; then
err "ERROR: unsupported ${CMD} target \"${TARGET}\"."
show_help 1>&2
exit 1
fi
if [[ -z ${KODEBUG+x} && -z "${TARGET}" && "${CMD}" != 'release' ]]; then
# For the emulator, build a debug build by default.
KODEBUG=1
fi
# Fetch third party as needed.
check_submodules
# Automatically install Android NDK / SDK when not configured.
if [[ "${TARGET}" == 'android' ]]; then
local wanted=()
[[ -n "${ANDROID_NDK_HOME}${ANDROID_NDK_ROOT}" ]] || wanted+=('android-ndk')
[[ -n "${ANDROID_HOME}${ANDROID_SDK_ROOT}" ]] || wanted+=('android-sdk')
[[ ${#wanted} -eq 0 ]] || TARGET='' run_make "${wanted[@]}"
fi
}
# }}}
# Common options handling. {{{
declare -r BUILD_GETOPT_SHORT='bdnv'
declare -r BUILD_GETOPT_LONG='no-build,debug,no-debug,verbose'
declare -r E_OPTERR=85
function build_options_help_msg() {
local section="$1"
local no_build_details="$2"
local debug_details="$3"
local no_debug_details="$4"
printf '%s' "${section}${section:+ }OPTIONS:
${no_build_details:+-b, --no-build do not build (}${no_build_details}${no_build_details:+)
}-d, --debug enable debugging symbols${debug_details:+ (}${debug_details}${debug_details:+)}
-n, --no-debug no debugging symbols${no_debug_details:+ (}${no_debug_details}${no_debug_details:+)}
-v, --verbose make the build system more verbose"
}
function parse_options() {
local short_opts="$1"
local long_opts="$2"
local args_spec="$3"
shift 3
# First things first: check if getopt is a compatible (util-linux like) version.
if getopt -T >/dev/null 2>&1 || [[ $? -ne 4 ]]; then
die 1 "unsupported getopt version: $(getopt --version)"
fi
if ! opt=$(getopt -o "h${short_opts}" --long "help,${long_opts}" --name "kodev" -- "$@"); then
show_help 1>&2
exit ${E_OPTERR}
fi
# echo "opt: $opt"
eval set -- "${opt}"
OPTS=()
ARGS=()
while true; do
case "$1" in
-h | --help)
show_help
exit 0
;;
-b | --no-build)
NO_BUILD=1
;;
-d | --debug)
KODEBUG=1
;;
-n | --no-debug)
KODEBUG=
;;
-v | --verbose)
# shellcheck disable=SC2034
VERBOSE=1
;;
--)
shift
break
;;
*)
OPTS+=("$1")
;;
esac
shift
done
local expected
local valid=0
case "${args_spec}" in
'*') ;;
'+')
expected='1 or more'
[[ $# -ge 1 ]] || valid=1
;;
'?')
expected='1 optional'
[[ $# -le 1 ]] || valid=1
;;
*)
expected="${args_spec}"
[[ $# -eq "${args_spec}" ]] || valid=1
;;
esac
if [[ ${valid} -ne 0 ]]; then
err "ERROR: invalid ${CMD} arguments; ${expected} expected but $# received"
show_help 1>&2
exit ${E_OPTERR}
fi
ARGS=("$@")
# echo "OPTS: ${OPTS[@]} [${#OPTS[@]}]"
# echo "ARGS: ${ARGS[@]} [${#ARGS[@]}]"
}
# }}}
# Command: activate / check / fetch-thirdparty. {{{
function kodev-activate() {
parse_options '' '' '0' "$@"
info "adding ${CURDIR} to \$PATH..."
export PATH="${PATH}:${CURDIR}"
eval "$(luarocks --lua-version=5.1 path --bin)"
exec "${SHELL}"
}
function kodev-check() {
parse_options '' '' '0' "$@"
check_submodules
"${CURDIR}/.ci/check.sh"
}
function kodev-fetch-thirdparty() {
HELP="
USAGE: $0 ${CMD} <OPTIONS>
OPTIONS:
-v, --verbose make the build system more verbose
"
parse_options "v" "verbose" '0' "$@"
run_make fetchthirdparty
}
# }}}
# Command: build / clean / release. {{{
function kodev-build() {
HELP="
USAGE: $0 ${CMD} <OPTIONS> <TARGET>
$(build_options_help_msg '' 'stop after the setup phase' 'default for emulator' 'default for other targets')
${TARGETS_HELP_MSG}
"
parse_options "${BUILD_GETOPT_SHORT}" "${BUILD_GETOPT_LONG}" '?' "$@"
setup_target "${ARGS[0]}"
run_make ${NO_BUILD:+setup}
}
function kodev-clean() {
HELP="
USAGE: $0 ${CMD} <OPTIONS> <TARGET>
$(build_options_help_msg '' '' 'clean debug build' 'clean release build')
${TARGETS_HELP_MSG}
"
parse_options "${BUILD_GETOPT_SHORT/b/}" "${BUILD_GETOPT_LONG/no-build,/}" '?' "$@"
setup_target "${ARGS[0]}"
run_make clean
}
function kodev-release() {
HELP="
USAGE: $0 ${CMD} <OPTIONS> <TARGET>
OPTIONS:
-i, --ignore-translation do not fetch translation for release
$(build_options_help_msg 'BUILD' 'create update from existing build' '' 'default')
${RELEASE_TARGETS_HELP_MSG}
"
parse_options "i${BUILD_GETOPT_SHORT}" "ignore-translation,${BUILD_GETOPT_LONG}" '1' "$@"
local ignore_translation=0
for opt in "${OPTS[@]}"; do
case "${opt}" in
-i | --ignore-translation)
ignore_translation=1
;;
esac
done
setup_target "${ARGS[0]}"
if [[ "${ignore_translation}" -eq 0 ]]; then
if ! TARGET='' run_make po; then
err "ERROR: failed to fetch translation."
echo "Tip: Use --ignore-translation OPTION if you want to build a release without translation." 2>&1
exit 1
fi
fi
run_make ${NO_BUILD:+--assume-old=all} update
}
# }}}
# Command: prompt / run / wbuilder. {{{
function kodev-prompt() {
HELP="
USAGE: $0 ${CMD} <OPTIONS>
$(build_options_help_msg '' 'use existing build' 'default' '')
"
parse_options "${BUILD_GETOPT_SHORT}" "${BUILD_GETOPT_LONG}" '0' "$@"
setup_target 'emulator'
local margs=()
if command -v rlwrap >/dev/null; then
margs+=(RWRAP='rlwrap')
fi
run_make ${NO_BUILD:+--assume-old=all} "${margs[@]}" run-prompt
}
function kodev-run() {
# Defaults.
KODEBUG=1
local screen_width=540
local screen_height=720
# NOTE: Speaking of Valgrind, if your libdrm/mesa isn't built w/ valgrind markings, there's a Valgrind suppression file for AMD cards in the tools folder.
# Just append --suppressions=${PWD/tools/valgrind_amd.supp to your valgrind command.
local valgrind=(valgrind --tool=memcheck --keep-debuginfo=yes --leak-check=full --show-reachable=yes --trace-children=yes --track-origins=yes)
local callgrind=(valgrind --tool=callgrind --trace-children=yes)
local wrap=()
HELP="
USAGE: $0 ${CMD} <OPTIONS> <EMULATOR ARGS>
$0 ${CMD} <OPTIONS> <ANDROID TARGET> [ANDROID APK]
$(build_options_help_msg '' 'use existing build' 'default' '')
EMULATOR OPTIONS:
-H X, --screen-height=X set height of the emulator screen (default: ${screen_height})
-W X, --screen-width=X set width of the emulator screen (default: ${screen_width})
-D X, --screen-dpi=X set DPI of the emulator screen (default: 160)
-t, --disable-touch use this if you want to simulate keyboard only devices
-s FOO --simulate=FOO simulate dimension and other specs for the given device:
hidpi, kobo-forma, kobo-aura-one, kobo-clara, kobo-h2o,
kindle-paperwhite, legacy-paperwhite, kindle
-g X, --gdb=X run with debugger (default: ddd, cgdb, or gdb)
--callgrind run with valgrind's callgrind
--valgrind[=X] run with valgrind
-w X, --wrap=X run with specified wrapper command
Extra arguments are forwarded to the emulator.
Default valgrind commands:
- callgrind: $(print_quoted "${callgrind[@]}")
- valgrind: $(print_quoted "${valgrind[@]}")
ANDROID TARGET:
Install and run KOReader on an Android device connected through ADB.
"
local short_opts="tg:::cW:H:D:s:w:"
local long_opts="disable-touch,gdb::,valgrind::,callgrind,screen-width:,screen-height:,screen-dpi:,simulate:,wrap:"
parse_options "${short_opts}${BUILD_GETOPT_SHORT}" "${long_opts},${BUILD_GETOPT_LONG}" '*' "$@"
# Handle custom options.
set -- "${OPTS[@]}"
while [[ $# -gt 0 ]]; do
PARAM="${1}"
# Support using an = assignment with short options (e.g., -f=blah instead of -f blah).
VALUE="${2/#=/}"
case "${PARAM}" in
# Command wrapper.
--callgrind)
# Try to use sensible defaults for valgrind.
if ! command -v valgrind >/dev/null; then
die 1 "Couldn't find valgrind."
fi
wrap=("${callgrind[@]}")
;;
-g | --gdb)
if [[ -n "${VALUE}" ]]; then
declare -a "wrap=(${VALUE})"
else
# Try to use friendly defaults for GDB:
# - DDD is a slightly less nice GUI
# - cgdb is a nice curses-based GDB front
# - GDB standard CLI has a fallback
if ! wrap=("$(command -v ddd cgdb gdb | head -n1)"); then
die 1 "Couldn't find GDB."
fi
fi
if [[ ${#wrap[@]} -eq 1 ]]; then
# The standard GDB CLI needs a little hand holding to
# properly pass arguments to the process it'll monitor.
local gdb_common_args=(--directory "${CURDIR}/base" --args)
case "${wrap[0]}" in
cgdb | */cgdb)
wrap+=(-- "${gdb_common_args[@]}")
;;
ddd | */ddd)
wrap+=(--gdb -- "${gdb_common_args[@]}")
;;
gdb | */gdb)
wrap+=("${gdb_common_args[@]}")
;;
esac
fi
shift
;;
--valgrind)
if [[ -n "${VALUE}" ]]; then
declare -a "wrap=(${VALUE})"
else
# Try to use sensible defaults for valgrind.
if ! command -v valgrind >/dev/null; then
die 1 "Couldn't find valgrind."
fi
wrap=("${valgrind[@]}")
fi
shift
;;
-w | --wrap)
declare -a "wrap=(${VALUE})"
shift
;;
# Simulated device specification.
-W | --screen-width)
screen_width="${VALUE}"
shift
;;
-H | --screen-height)
screen_height="${VALUE}"
shift
;;
-D | --screen-dpi)
screen_dpi="${VALUE}"
shift
;;
-s | --simulate)
case "${VALUE}" in
kindle)
screen_width=600 screen_height=800 screen_dpi=167
;;
legacy-paperwhite)
screen_width=758 screen_height=1024 screen_dpi=212
;;
kobo-forma)
screen_width=1440 screen_height=1920 screen_dpi=300
;;
kobo-aura-one)
screen_width=1404 screen_height=1872 screen_dpi=300
;;
kobo-clara | kindle-paperwhite)
screen_width=1072 screen_height=1448 screen_dpi=300
;;
kobo-h2o)
screen_width=1080 screen_height=1429 screen_dpi=265
;;
hidpi)
screen_width=1500 screen_height=2000 screen_dpi=600
;;
*)
die 1 "ERROR: spec unknown for ${VALUE}."
;;
esac
shift
;;
-t | --disable-touch)
export DISABLE_TOUCH=1
;;
esac
shift
done
set -- "${ARGS[@]}"
# Setup target.
local target=''
if [[ "$1" = android-* ]]; then
target="$1"
shift
fi
setup_target "${target}"
# Build command prefix.
local rwrap=()
if [[ -z "${target}" ]]; then
rwrap+=(EMULATE_READER_W="${screen_width}" EMULATE_READER_H="${screen_height}" EMULATE_READER_DPI="${screen_dpi}")
fi
if [[ "${#wrap[@]}" -gt 0 ]]; then
rwrap+=("${wrap[@]}")
fi
# Build the final make command.
local margs=()
if [[ "${TARGET}" == 'android' ]]; then
if [[ "$1" = *.apk ]]; then
margs+=(ANDROID_APK="$1")
NO_BUILD=1
shift
fi
if [[ ${#rwrap[@]} -gt 0 || $# -gt 0 ]]; then
show_help 1>&2
exit ${E_OPTERR}
fi
else
# Enable debug traces by default.
set -- -d "$@"
fi
if [[ ${#rwrap[@]} -gt 0 ]]; then
margs+=(RWRAP="$(print_quoted "${rwrap[@]}")")
fi
if [[ $# -gt 0 ]]; then
margs+=(RARGS="$(print_quoted "$@")")
fi
# Run it.
run_make "${margs[@]}" ${NO_BUILD:+--assume-old=all --assume-old=update} run
}
function kodev-wbuilder() {
HELP="
USAGE: $0 ${CMD} <OPTIONS>
$(build_options_help_msg '' '' '' '')
"
parse_options "${BUILD_GETOPT_SHORT}" "${BUILD_GETOPT_LONG}" '0' "$@"
setup_target 'emulator'
run_make run-wbuilder
}
# }}}
# Command: cov / test. {{{
function kodev-cov() {
HELP="
USAGE: $0 ${CMD} <OPTIONS>
OPTIONS:
-f, --full show full coverage report (down to each line)
-s, --show-previous show coverage stats from previous run
$(build_options_help_msg 'BUILD' 'use existing build' '' 'default')
"
parse_options "fs${BUILD_GETOPT_SHORT}" "full,show-previous,${BUILD_GETOPT_LONG}" '0' "$@"
# Handle custom options.
local show_full=''
local show_previous=''
for opt in "${OPTS[@]}"; do
case "${opt}" in
-f | --full)
show_full=1
;;
-s | --show-previous)
show_previous=1
;;
esac
done
setup_target 'emulator'
run_make ${NO_BUILD:+--assume-old=all} ${show_previous:+--assume-old=coverage-run} coverage${show_full:+-full}
}
function kodev-test() {
HELP="
USAGE: $0 ${CMD} <OPTIONS> <TEST_SUITE> <TEST_NAMES>
TEST_SUITE: [all|base|front]. Optional: default to all.
TEST_NAMES: if no TEST_NAMES are given, the full testsuite is run.
OPTIONS:
-t, --tags=TAGS only run tests with given tags
$(build_options_help_msg 'BUILD' 'use existing build' '' 'default')
"
parse_options "t:${BUILD_GETOPT_SHORT}" "tags:,${BUILD_GETOPT_LONG}" '*' "$@"
# Handle first argument.
suite=''
set -- "${ARGS[@]}"
if [[ $# -ne 0 ]]; then
suite="$1"
shift
ARGS=("$@")
fi
# The rest (custom options included) is forwarded to busted.
setup_target 'emulator'
run_make ${NO_BUILD:+--assume-old=all} "test${suite}" BUSTED_OVERRIDES="$(print_quoted "${OPTS[@]}" "${ARGS[@]}")"
}
# }}}
# Command: log. {{{
function kodev-log() {
env PYTHONEXECUTABLE="$0 ${CMD}" ./tools/logcat.py "$@"
}
# }}}
HELP_MSG="
USAGE: $0 COMMAND <ARGS>
Supported commands:
Building:
build Build KOReader
clean Clean KOReader build
release Build KOReader release package
Emulator & Android:
run Run KOReader
Emulator only:
cov Run busted tests for coverage
prompt Run a LuaJIT shell within KOReader's environment
test Run busted tests
wbuilder Run wbuilder.lua script (useful for building new UI widget)
Android only:
log Tail log stream for a running KOReader app
Miscellaneous:
activate Bootstrap shell environment for kodev
fetch-thirdparty Fetch & synchronize thirdparty dependencies
check Run various linters
"
if [[ $# -lt 1 ]]; then
err "Missing command."
echo "${HELP_MSG}" 1>&2
exit 1
fi
CMD="$1"
shift
case "${CMD}" in
# Commands.
activate) ;;
build) ;;
check) ;;
clean) ;;
cov) ;;
fetch-thirdparty) ;;
log) ;;
prompt) ;;
release) ;;
run) ;;
test) ;;
wbuilder) ;;
# Options.
-h | --help)
echo "${HELP_MSG}"
exit 0
;;
# Invalid.
*)
err "Unknown command: $1."
echo "${HELP_MSG}"
exit 8
;;
esac
HELP="USAGE: $0 ${CMD}"
"kodev-${CMD}" "$@"
# vim: foldmethod=marker foldlevel=0 shiftwidth=4 softtabstop=4