summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Schafft <lion@lion.leolix.org>2017-05-01 10:35:12 +0000
committerPhilipp Schafft <lion@lion.leolix.org>2017-05-01 16:13:46 +0000
commit347fd1f8fcf6c14fe936eb4c4c21d101c6e24ca7 (patch)
treef4f4dd3cf6069f1f19a8fc7bdc55dd7c2fd86799
parentd7cf3b4217a4a6ef16ade15f32170894a66d5b52 (diff)
Feature: Added basic plugin supportplugins
This includes support to run plugins as --preprocessor and a newly added --generate.
-rwxr-xr-xwebgen39
1 files changed, 39 insertions, 0 deletions
diff --git a/webgen b/webgen
index 660b087..41e47b7 100755
--- a/webgen
+++ b/webgen
@@ -47,8 +47,34 @@ DEFAULT_MENU='-menu-none'
PREPROCESSOR='none'
LANGUAGE=''
TEMPLATES=''
+PLUGINS=''
# CODE:
+call_plugin() {
+# Args: plugin, mode, input, output, args...
+ _plugin="$1"
+ _mode="$2"
+ _input="$3"
+ _output="$4"
+ shift 4
+
+ "webgenp-$_plugin" --tpl . --mode "$_mode" --input "$_input" --output "$_output" "$@"
+}
+
+generate() {
+ cd $TPLS
+ if [ -z "$PLUGINS" ]
+ then
+ PLUGINS=`cat \#plugin`
+ fi
+
+ for _p in $PLUGINS
+ do
+ echo "Calling plugin $_p"
+ call_plugin "$_p" generate . .
+ done
+}
+
setup() {
if [ -e $TPLS -o -e Makefile ]
then
@@ -209,6 +235,7 @@ list_dependencies() {
show_help() {
echo "Usage: webgen [--preprocessor PP] [--language LANG] [{+|~|=}][TPL]"
echo " or: webgen [--language LANG] --list-dependencies [{+|~|=}]TPL"
+ echo " or: webgen [--plugin PLUGIN] --generate"
echo " or: webgen --setup"
echo " or: webgen --list"
echo " or: webgen --help"
@@ -221,6 +248,10 @@ do
PREPROCESSOR="$2"
shift
;;
+ '--plugin')
+ PLUGINS="$PLUGINS $2"
+ shift
+ ;;
'--language')
if [ "$2" = 'default' ]
then
@@ -236,6 +267,10 @@ do
popd > /dev/null
shift;
;;
+ '--generate')
+ generate
+ exit 0
+ ;;
'--setup')
setup
exit 0
@@ -278,6 +313,10 @@ cat_file() {
cpp)
cpp -P -o - -D__TEMPLATE__="\"$_tpl\"" -D__TEMPLATE_CLEAN__="\"$CLEANTPLNAME\"" -D __OUTPUT_FILE__="\"$OF\"" ./"$_file"
;;
+ plugin-*)
+ _plugin=`echo "$PREPROCESSOR" | sed 's/^plugin-//'`;
+ call_plugin "$_plugin" preprocessor "$_file" - --kv template "$_tpl" --kv template-clean "$CLEANTPLNAME" --kv output-file "$OF"
+ ;;
*)
echo "Error: Unknown preprocessor: $PREPROCESSOR" >&2
;;