eureka/build.sh

78 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/sh
# copy default config if none
if [ ! -e config.h ]; then
cp config.def.h config.h
fi
# ensure sane environment
if [ ! -d inc ]; then
mkdir inc
fi
if [ ! -e inc/meta.nav.htm ]; then
touch inc/meta.nav.htm
fi
# Lint
2024-09-27 01:32:04 +00:00
if which clang-format > /dev/null; then
clang-format -i main.c config.h
fi
# Cleanup
rm -f ./main
# Linux(debug)
2024-09-27 01:32:04 +00:00
# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main
# Linux(fast)
cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main
# RPi
# tcc -Wall main.c -o main
# Plan9
# pcc main.c -o main
# Valgrind
# gcc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og main.c -o main
# valgrind ./main
# Build Size
# echo "$(du -b ./main | cut -f1) bytes written"
# Run
2022-06-19 05:37:19 +00:00
if [ "$1" = "-r" ]; then
regen="true"
shift
fi
if [ "$1" = "-d" ]; then
shift
tmptwtxt=$(mktemp)
tail -n +2 ../www/twtxt.txt > ${tmptwtxt}
cp ${tmptwtxt} ../www/twtxt.txt
rm ${tmptwtxt}
echo "Deleted latest twtxt"
fi
if [ "$1" = "-t" ]; then
shift && ./tw.sh $@
2022-06-19 05:37:19 +00:00
echo "Twtxt added"
fi
./main
exitstatus=$?
if [ "${exitstatus}" = "0" ]; then
2022-06-19 05:37:19 +00:00
if [ "${regen}" = "true" ]; then
echo "Clearing thumbnails and regenerating in the background"
(./thumbnailer.sh clean > /dev/null 2>&1; ./thumbnailer.sh build > /dev/null 2>&1) &
else
echo "Generating thumbnails in the background"
(./thumbnailer.sh build > /dev/null 2>&1) &
fi
fi
# Cleanup
rm -f ./main
exit ${exitstatus}