From 2df40bb5b6e480061ec66e82aeab357ad4498355 Mon Sep 17 00:00:00 2001 From: Mikhail Kobuk Date: Sat, 13 Apr 2024 03:18:44 +0300 Subject: Add build system --- build.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 build.sh (limited to 'build.sh') diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cf09148 --- /dev/null +++ b/build.sh @@ -0,0 +1,40 @@ +#! /bin/bash + +# USE: ./build.sh [sources] + +pancompile="$1 $2 $3" +panexec="$1" +panflags="$2" +panformat="$3" +sources=${@:4} + +echo "using command <${pancompile}>" +echo "for sources: ${sources}" + +for src in ${sources}; do + if [ -d ${src} ]; then + printf "\tfound dir: ${src}\n" + + if [ "$(find ${src} -name '*.md' | wc -l)" != "1" ]; then + printf "\tToo many files in dir. Won't build. Skipping.\n" + continue + fi + + indir_src="$(find ${src} -name '*.md')" + indir_out="${indir_src##*/}" + ${panexec} ${panflags} ${indir_src} ${panformat} -o ${indir_out%.*}.html + + elif [ -f ${src} ] && [ "${src##*.}" == "md" ]; then + printf "\tfound md file: ${src}\n" + + printf "\t${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html" + ${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html + else + echo "unknown source" + exit 1 + fi +done + +#for lab in $(find . -maxdepth 1 -name "lab*" -type d); do +# echo "Found directory ${lab}" +#done -- cgit v1.2.3-70-g09d2