aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-25 16:43:10 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-25 16:43:10 +0200
commit10b5caed980eea277603c5a8aab26963445eb9a6 (patch)
tree0293c0d25bb2a5c7ec25eb96d7466180533047b5
parent6ea7f3a91f069917a03c28d5d006cbed15e0b03f (diff)
replace makec with mk script
-rwxr-xr-x.local/share/bin/makec18
-rwxr-xr-x.local/share/bin/mk44
-rw-r--r--.profile1
3 files changed, 44 insertions, 19 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
+
diff --git a/.profile b/.profile
index 6e6e07b..1a82b4a 100644
--- a/.profile
+++ b/.profile
@@ -12,7 +12,6 @@ alias cls='clear'
alias vim='nvim'
alias copy='xclip -selection c'
alias dnd='dragon-drag-and-drop -a -x'
-alias mk='make'
alias sl='sl -w'
alias vv='neovide'
alias today='khal list today today'