summaryrefslogtreecommitdiffstats
path: root/make.sh
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-27 16:58:01 +0200
committerSimon Rettberg2019-05-27 16:58:01 +0200
commit58a01fd257b6f190d6a44662fbd78944fbc608aa (patch)
tree9c92b4b9f7bf6acf4b710a29e56ca638db73a09b /make.sh
parentMatch proper field (diff)
downloadslx-tools-58a01fd257b6f190d6a44662fbd78944fbc608aa.tar.gz
slx-tools-58a01fd257b6f190d6a44662fbd78944fbc608aa.tar.xz
slx-tools-58a01fd257b6f190d6a44662fbd78944fbc608aa.zip
Modularize
Diffstat (limited to 'make.sh')
-rwxr-xr-xmake.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/make.sh b/make.sh
new file mode 100755
index 0000000..a8a4760
--- /dev/null
+++ b/make.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+if [ -z "$1" ]; then
+ echo "Pass abolute path to where slx-tools will be located"
+ exit 1
+fi
+
+declare -rg BASE="$1"
+
+shopt -s globstar
+set -e
+
+
+DEFS=
+
+for file in modules/**/*.inc; do
+ name="${file#modules/}"
+ name="${name//\//_}"
+ name="${name%.inc}"
+ [[ "$name" =~ ^[a-z0-9_]+$ ]] || continue
+ echo " * Handling $file"
+ for var in $( grep -oP '^[a-z0-9_]+\s*\(\)' "$file" | grep -oE '^[a-z0-9_]+' ); do
+ echo "Found $var"
+ DEFS+="$var() { . \$BASE/$file; $var "'"$@"; }\n'
+ done
+done
+
+sed "s#%DEFS%#${DEFS}#;s#^BASE=.*\$#BASE='$BASE'#" slx-tools.template > slx-tools
+chmod +x slx-tools
+