diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-05-11 04:18:08 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-05-11 04:18:12 +0300 |
commit | 0aba139aeff8ff80757c5d36502413299a0b449e (patch) | |
tree | 2b8e760ff14d4691783eb7c7d341f093199aab82 /platformio/relayctl/make_static.sh | |
parent | 586d84b0c0a8b4dc1b5057733892b754397234ec (diff) |
mqtt, esp: add new esp8266-based device
Diffstat (limited to 'platformio/relayctl/make_static.sh')
-rwxr-xr-x | platformio/relayctl/make_static.sh | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/platformio/relayctl/make_static.sh b/platformio/relayctl/make_static.sh deleted file mode 100755 index 879beb4..0000000 --- a/platformio/relayctl/make_static.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -#set -x -#set -e - -DIR="$(dirname "$(realpath "$0")")" - -fw_version="$(cat "$DIR/src/config.def.h" | grep "^#define FW_VERSION" | awk '{print $3}')" -header="$DIR/src/static.h" -source="$DIR/src/static.cpp" - -[ -f "$header" ] && rm "$header" -[ -f "$source" ] && rm "$source" - -is_minifyable() { - local ext="$1" - [ "$ext" = "html" ] || [ "$ext" = "css" ] || [ "$ext" = "js" ] -} - -minify() { - local ext="$1" - local bin="$(realpath "$DIR"/../../tools/minify.js)" - "$bin" --type "$ext" -} - -# .h header -cat <<EOF >> "$header" -/** - * This file is autogenerated with make_static.sh script - */ - -#pragma once - -#include <stdlib.h> - -namespace homekit::files { - -typedef struct { - size_t size; - const uint8_t* content; -} StaticFile; - -EOF - -cat <<EOF >> "$source" -/** - * This file is autogenerated with make_static.sh script - */ - -#include "static.h" - -namespace homekit::files { - -EOF - -# loop over files -for ext in html js css ico; do - for f in "$DIR"/static/*.$ext; do - filename="$(basename "$f")" - echo "processing ${filename}..." - filename="${filename/./_}" - - # write .h - echo "extern const StaticFile $filename;" >> "$header" - - # write .c - { - echo "static const uint8_t ${filename}_content[] PROGMEM = {" - - cat "$f" | - ( [ "$ext" = "html" ] && sed "s/{version}/$fw_version/" || cat ) | - ( is_minifyable "$ext" && minify "$ext" || cat ) | - gzip | - xxd -ps -c 16 | - sed 's/.\{2\}/0x&, /g' | - sed 's/^/ /' | - sed 's/[ \t]*$//' - - echo "};" - echo "const StaticFile $filename PROGMEM = {(sizeof(${filename}_content)/sizeof(${filename}_content[0])), ${filename}_content};" - echo "" - } >> "$source" - done -done - -# end of homekit::files -( echo ""; echo "}" ) >> "$header" -echo "}" >> "$source" |