blob: 54b690854de84eecbcc8cd966a88e781dceb76e5 (
plain)
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
|
#!/bin/sh
progname="$(basename "$0")"
showmode() {
! [ -n "$FROM_PROMPT" ] && return
! [ -t 1 ] && return
mode=" ($1)"
col=$(( $(tput cols) - $(echo "$mode" | wc -L) + 1 ))
printf '\e[1A\e['$col'G\e[1;30m%s\e[0m\n' "$mode"
}
mode_west() {
showmode 'west'
[ -z "$*" ] && set -- build
exec west "$@"
}
[ -e "west.yml" ] && mode_west "$@"
mode_cmake() {
showmode 'cmake'
builddir="build"
[ "$*" = "clean" ] && exec rm -rf "$builddir"
export CMAKE_GENERATOR="Ninja"
# re-run configuration if fresh or CMakeLists was changed
if [ ! -e "$builddir/build.ninja" ] ||
[ "CMakeLists.txt" -nt "$builddir/build.ninja" ] ; then
cmake --log-level WARNING -B "$builddir"
fi
# build
cmake --build "$builddir" -- "$@" || exit $?
# generate vim tags (continue after mk exits)
ninja -C "$builddir" -t deps | sed -n 's/^ \{4\}//p' | sort -u | ctags -L - -f "$builddir/tags" &
exit 0
}
[ -e "CMakeLists.txt" ] && mode_cmake "$@"
mode_make() {
showmode 'make'
exec make "$@"
}
[ -e "makefile" ] && mode_make "$@"
[ -e "Makefile" ] && mode_make "$@"
mode_latexmk() {
showmode 'latexmk'
[ "$*" = "clean" ] && exec latexmk -c
exec latexmk "$@"
}
[ -e "latexmkrc" ] && mode_latexmk "$@"
[ -e ".latexmkrc" ] && mode_latexmk "$@"
echo "$progname: unable to determine project build system!" >&2
exit 1
|