[test/Makefile] Auto-generate .gitignore for test executables

This commit is contained in:
Connor Gibson
2025-05-24 18:28:27 -07:00
parent 365690f612
commit 7d30759eac

View File

@@ -11,7 +11,7 @@ xotests = wiringpi_xotest_test1_spi wiringpi_i2c_test1_pcf8574 wiringpi_test8_pw
# Need PiFace hardware and BCM23 <-> BCM24 , BCM18 <-> BCM17 connected (1kOhm), and PiFace Out7<->In4, Out6<->In5, R0_NO<->In6, R0_NO<->In7, R_C<-100Ohm->GND
pifacetests = wiringpi_piface_test1 wiringpi_test8_pwm wiringpi_test9_pwm
all: $(tests) $(xotests) $(pifacetests)
all: $(tests) $(xotests) $(pifacetests) .gitignore
wiringpi_test0_version:
${CC} ${CFLAGS} wiringpi_test0_version.c -o wiringpi_test0_version -lwiringPi
@@ -113,7 +113,23 @@ pifacetest:
echo "\n\e[5mPIFACE TEST SUCCESS\e[0m\n"; \
fi
# Add all binaries to a folder-local .gitignore file
.gitignore:
@echo "Updating test directory .gitignore..."
@if ! test -f "./.gitignore"; then \
echo "# This file is automatically generated by make." >> .gitignore; \
echo "# Git will ignore this file and all generated WiringPi test binaries in this folder." >> .gitignore; \
echo "/.gitignore" >> .gitignore; \
fi
@for t in $(tests) $(xotests) $(pifacetests) ; do \
if ! grep -q "/$$t" .gitignore; then \
echo "/$$t" >> .gitignore; \
echo "Added /$$t to .gitignore"; \
fi; \
done
clean:
for t in $(tests) $(xotests) $(pifacetests) ; do \
rm -fv $${t} ; \
done
rm -fv .gitignore