Skip to content

Commit

Permalink
build: accept silent arg in the client build script to use it cleanly…
Browse files Browse the repository at this point in the history
… in Makefile

set loglevel to warning so in case of warnings or errors when building the client
when running the Makefile it will keep some output
  • Loading branch information
ttytm committed Aug 14, 2023
1 parent c867255 commit a192c76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ debug: --eval-args client $(BUILD_TARGET)-debug

client:
@echo "Build WebUI js client..."
@src/client/build.sh
@src/client/build.sh --silent

# Internal Targets

Expand Down
29 changes: 21 additions & 8 deletions src/client/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@
project_root=$(git rev-parse --show-toplevel)
cd $project_root/src/client

# TODO: silent arg
# Transpiling TS to JS
echo "Transpile and bundle TS sources to webui.js";
esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=. ./webui.ts
# Loop through all arguments
for opt in "$@"; do
case $opt in
--silent)
silent=true
;;
*)
echo "Invalid option: $opt"
exit 0
;;
esac
shift # Move to the next argument
done

# Converting JS source to C-String using xxd
echo "Converting JS source to C-String using xxd"
# The path needs to match the path in webui.c, that's why we move up to src/
if [ "$silent" = true ]; then log_level=--log-level=warning; fi

if [ "$silent" != true ]; then echo "Transpile and bundle TS sources to webui.js"; fi
esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=. ./webui.ts $log_level

if [ "$silent" != true ]; then echo "Convert JS source to C-String using xxd"; fi
cd ..
# The path needs to match the path in webui.c, that's why we move up to src/
xxd -i client/webui.js client/webui.h

echo "Finished."
if [ "$silent" != true ]; then echo "Finished."; fi

0 comments on commit a192c76

Please sign in to comment.