diff options
Diffstat (limited to '.local/share')
-rwxr-xr-x | .local/share/bin/makec | 18 | ||||
-rwxr-xr-x | .local/share/bin/mk | 44 |
2 files changed, 44 insertions, 18 deletions
diff --git a/.local/share/bin/makec b/.local/share/bin/makec deleted file mode 100755 index e89ced1..0000000 --- a/.local/share/bin/makec +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# mini wrapper around CMake + Ninja to build in one command - -BUILD_DIR="build" -CMAKE="cmake --fresh --log-level WARNING -Wno-deprecated" - -if [ ! -e "$BUILD_DIR/build.ninja" ] || - [ "CMakeLists.txt" -nt "$BUILD_DIR/build.ninja" ] ; then - $CMAKE -B "$BUILD_DIR" -G Ninja -fi - -if [ "$*" = "clean" ] ; then - rm -rf "$BUILD_DIR" - exit 0 -fi - -exec ninja -C "$BUILD_DIR" "$@" - diff --git a/.local/share/bin/mk b/.local/share/bin/mk new file mode 100755 index 0000000..2a046d6 --- /dev/null +++ b/.local/share/bin/mk @@ -0,0 +1,44 @@ +#!/bin/sh +progname="$(basename "$0")" +showmode() { + 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_cmake() { + showmode 'cmake' + builddir="build" + + [ "$*" = "clean" ] && exec rm -rf "$builddir" + + # 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" -G Ninja + fi + + exec ninja -C "$builddir" "$@" +} +[ -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 + |