aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh41
-rw-r--r--copyright2
-rwxr-xr-xprocess_html_file.sh33
-rw-r--r--shell_utils.sh39
4 files changed, 80 insertions, 35 deletions
diff --git a/build.sh b/build.sh
index 60c1863..d940176 100755
--- a/build.sh
+++ b/build.sh
@@ -3,36 +3,7 @@
# Copyright (C) 2021 Wojtek Kosior
# Redistribution terms are gathered in the `copyright' file.
-ENDL="
-"
-
-errcho() {
- echo "$@" >&2
-}
-
-map_set_instr() {
- echo "$1__$2='$3'"
-}
-
-map_set() {
- eval "$(map_set_instr "$@")"
-}
-
-map_get() {
- eval "echo \"\$$1__$2\""
-}
-
-map_del_instr() {
- echo "unset $1__$2"
-}
-
-map_del() {
- eval "$(map_del_instr "$@")"
-}
-
-sanitize() {
- echo "$1" | tr /.- _
-}
+. ./shell_utils.sh
handle_export_line() {
if [ "x$1" = "xEXPORTS_START" ]; then
@@ -259,11 +230,13 @@ s^_BGSCRIPTS_^$BGSCRIPTS^
s^_CONTENTSCRIPTS_^$CONTENTSCRIPTS^" \
< manifest.json > $BUILDDIR/manifest.json
- sed "s^_POPUPSCRIPTS_^$POPUPSCRIPTS^" \
- < html/display-panel.html > $BUILDDIR/html/display-panel.html
+ ./process_html_file.sh html/display-panel.html |
+ sed "s^_POPUPSCRIPTS_^$POPUPSCRIPTS^" \
+ > $BUILDDIR/html/display-panel.html
- sed "s^_OPTIONSSCRIPTS_^$OPTIONSSCRIPTS^" \
- < html/options.html > $BUILDDIR/html/options.html
+ ./process_html_file.sh html/options.html |
+ sed "s^_OPTIONSSCRIPTS_^$OPTIONSSCRIPTS^" \
+ > $BUILDDIR/html/options.html
for FILE in $SCRIPTS; do
FILEKEY=$(sanitize "$FILE")
diff --git a/copyright b/copyright
index 36340e4..96de092 100644
--- a/copyright
+++ b/copyright
@@ -6,7 +6,7 @@ Files: *
Copyright: 2021 Wojtek Kosior <koszko@koszko.org>
License: GPL-3+-javascript or Alicense-1.0
-Files: re-generate_icons.sh build.sh
+Files: *.sh
Copyright: 2021 Wojtek Kosior <koszko@koszko.org>
2021 jahoti <jahoti@tilde.team>
License: CC0
diff --git a/process_html_file.sh b/process_html_file.sh
new file mode 100755
index 0000000..1ed0295
--- /dev/null
+++ b/process_html_file.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Copyright (C) 2021 Wojtek Kosior
+# Redistribution terms are gathered in the `copyright' file.
+
+# Call like:
+# ./process_html_file.sh html/options.html
+
+. ./shell_utils.sh
+
+FILE="$1"
+FILEKEY=$(sanitize "$FILE")
+
+if [ "x$(map_get HTML_FILENAMES $FILEKEY)" = "xyes" ]; then
+ errcho "import loop on $FILE"
+ exit 1
+fi
+
+map_set_export HTML_FILENAMES $FILEKEY yes
+
+awk '\
+!/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
+ print $0;
+}
+/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
+ indent = substr($0, 1, index($0, "<") - 1);
+ command = "./process_html_file.sh " $2;
+ while (command | getline) {
+ print indent $0;
+ }
+ if (close(command) != 0)
+ exit 1;
+}' < "$FILE"
diff --git a/shell_utils.sh b/shell_utils.sh
new file mode 100644
index 0000000..95e0d4e
--- /dev/null
+++ b/shell_utils.sh
@@ -0,0 +1,39 @@
+# Copyright (C) 2021 Wojtek Kosior
+# Redistribution terms are gathered in the `copyright' file.
+
+# This file is meant to be sourced in sh.
+
+ENDL="
+"
+
+errcho() {
+ echo "$@" >&2
+}
+
+map_set_instr() {
+ echo "$1__$2='$3'"
+}
+
+map_set() {
+ eval "$(map_set_instr "$@")"
+}
+
+map_set_export() {
+ eval "export $(map_set_instr "$@")"
+}
+
+map_get() {
+ eval "echo \"\$$1__$2\""
+}
+
+map_del_instr() {
+ echo "unset $1__$2"
+}
+
+map_del() {
+ eval "$(map_del_instr "$@")"
+}
+
+sanitize() {
+ echo "$1" | tr /.- _
+}