Only format when clang-format is present

This commit is contained in:
neauoire 2021-06-25 19:03:56 -07:00
parent 93ac1045e8
commit 606c7707ff
1 changed files with 22 additions and 15 deletions

View File

@ -1,5 +1,15 @@
#!/usr/bin/env bash
echo "Cleaning.."
rm -f ./bin/uxnasm
rm -f ./bin/uxnemu
rm -f ./bin/uxncli
rm -f ./bin/boot.rom
# When clang-format is present
if command -v clang-format &> /dev/null
then
echo "Formatting.."
clang-format -i src/uxn.h
clang-format -i src/uxn.c
@ -12,16 +22,12 @@ clang-format -i src/devices/mpu.c
clang-format -i src/uxnasm.c
clang-format -i src/uxnemu.c
clang-format -i src/uxncli.c
echo "Cleaning.."
rm -f ./bin/uxnasm
rm -f ./bin/uxnemu
rm -f ./bin/uxncli
rm -f ./bin/boot.rom
fi
mkdir -p bin
CFLAGS="-std=c89 -Wall -Wno-unknown-pragmas"
UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
if cc ${CFLAGS} -c src/devices/mpu.c -o bin/mpu.o 2>/dev/null; then
rm -f bin/mpu.o
echo "Building with portmidi.."
@ -30,6 +36,7 @@ else
echo "Building without portmidi.."
CFLAGS="${CFLAGS} -DNO_PORTMIDI"
fi
if [ "${1}" = '--debug' ];
then
echo "[debug]"
@ -39,17 +46,17 @@ else
CFLAGS="${CFLAGS} -DNDEBUG -Os -g0 -s"
CORE='src/uxn-fast.c'
fi
cc ${CFLAGS} src/uxnasm.c -o bin/uxnasm
cc ${CFLAGS} ${CORE} src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
cc ${CFLAGS} ${CORE} src/uxncli.c -o bin/uxncli
echo "Installing.."
if [ -d "$HOME/bin" ] && [ -e ./bin/uxnemu ] && [ -e ./bin/uxnasm ]
then
echo "Installing in $HOME/bin"
cp ./bin/uxnemu $HOME/bin
cp ./bin/uxnasm $HOME/bin
cp ./bin/uxncli $HOME/bin
echo "Installed in $HOME/bin"
fi
echo "Assembling.."