2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

kodev: rewrite most of it

Factorize (options handling, target setup, …), add explicit
Android targets (`android-arm`, `android-arm64`, etc…).

build:
- support `--no-build` / `-b`: only run setup phase

check: simplify implementation (re-use `.ci/check.sh`)

cov & test:
- forward to makefile rules (no need to guess install directory)
- support `--no-build` / `-b`: use existing build

log:
- drop the target argument (since only Android is supported anyway)

prompt & wbuilder:
- forward to makefile rules (no need to guess install directory)
- support `--no-build` / `-b`: use existing build

release:
- support `--no-build` / `-b`: use existing build

run:
- forward to makefile rules (no need to guess install directory)
- correctly support relative arguments, and whitespace in arguments
- drop support for catchsegv: Glibc 2.35 (2022) dropped catchsegv and
  associated `libSegFault.so` shared library
- drop support for nemiver debugger: project is dead, last release
  was 8 years ago, repo is archived, and package has been dropped
  from newer Debian / Ubuntu releases
- support running an APK passed as argument when using `android` target
- rename short `-d`, `-h`, and `-w` options to `-D`, `-H` and `-W`
  respectively (to avoid conflicts with standard options)
- drop support for `-p` / `--graph` argument: code moved to a dedicated
  wrapper script (`tools/graph_memory.sh`) that can be used with the new
  `-w` / `--wrap` argument: `./kodev run -w tools/graph_memory.sh …`
- drop `--tui` argument when using GDB: said TUI does not cohabit well
  with KOReader console outputs (and cgdb is better fancy TUI anyway)
This commit is contained in:
Benoit Pierre 2024-08-11 20:58:28 +02:00 committed by Frans de Jonge
parent 9c70a3d6a9
commit f586613f94
2 changed files with 684 additions and 1097 deletions

1714
kodev

File diff suppressed because it is too large Load Diff

67
tools/graph_memory.sh Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
# inspired by https://gist.github.com/nicolasazrak/32d68ed6c845a095f75f037ecc2f0436
# Takes two arguments:
# $1 arguments to pass to pgrep
# $2 process name to pgrep for
function gnuplot_wrapper() {
TEMP_DIR="$(mktemp --directory /tmp/tmp.koreaderXXX)"
LOG="${TEMP_DIR}/memory.log"
SCRIPT_PNG="${TEMP_DIR}/script_png.p"
SCRIPT_SHOW="${TEMP_DIR}/script_show.p"
IMAGE_PNG="${TEMP_DIR}/graph.png"
echo "Memory plot output to ${TEMP_DIR}"
cat >"${SCRIPT_PNG}" <<EOL
set term pngcairo size 1600,1200
set output "${IMAGE_PNG}"
set ylabel "RSS"
set y2label "VSZ"
set ytics nomirror
set y2tics nomirror in
set yrange [0:*]
set y2range [0:*]
plot "${LOG}" using 3 with lines axes x1y1 title "RSS", "${LOG}" using 2 with lines axes x1y2 title "VSZ"
EOL
# Launch program.
"$@" &
PROG_PID=$!
trap 'kill "${PROG_PID}"' INT
# Initialize at 0 so gnuplot has something to show.
echo "0 0 0" >"${LOG}"
gnuplot "${SCRIPT_SHOW}" &
GNUPLOT_PID=$!
cat >"${SCRIPT_SHOW}" <<EOL
set term qt noraise
set ylabel "RSS"
set y2label "VSZ"
set ytics nomirror
set y2tics nomirror in
set yrange [0:*]
set y2range [0:*]
while (1) {
plot "${LOG}" using 3 with lines axes x1y1 title "RSS", "${LOG}" using 2 with lines axes x1y2 title "VSZ"
pause 1
system("ps -p ${PROG_PID} -o pid= >/dev/null 2>&1")
if (GPVAL_SYSTEM_ERRNO != 0) {
break
}
}
EOL
while ps -p "${PROG_PID}" -o pid=,vsz=,rss= >>"${LOG}"; do
sleep 1
done
wait ${GNUPLOT_PID}
gnuplot "${SCRIPT_PNG}"
}
gnuplot_wrapper "$@"
# vim: sw=4