commit 606c7707ff8936aab3d6a579f8cfbe23062e2a21
parent 93ac1045e888b94e7a6038b332e568ae9e32d189
Author: neauoire <aliceffekt@gmail.com>
Date: Fri, 25 Jun 2021 19:03:56 -0700
Only format when clang-format is present
Diffstat:
M | build.sh | | | 37 | ++++++++++++++++++++++--------------- |
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/build.sh b/build.sh
@@ -1,27 +1,33 @@
#!/usr/bin/env bash
-echo "Formatting.."
-clang-format -i src/uxn.h
-clang-format -i src/uxn.c
-clang-format -i src/devices/ppu.h
-clang-format -i src/devices/ppu.c
-clang-format -i src/devices/apu.h
-clang-format -i src/devices/apu.c
-clang-format -i src/devices/mpu.h
-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
+# 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
+ clang-format -i src/devices/ppu.h
+ clang-format -i src/devices/ppu.c
+ clang-format -i src/devices/apu.h
+ clang-format -i src/devices/apu.c
+ clang-format -i src/devices/mpu.h
+ 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
+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.."