From 7d30759eacceff255c001f8d2af5be01203f2a31 Mon Sep 17 00:00:00 2001 From: Connor Gibson Date: Sat, 24 May 2025 18:28:27 -0700 Subject: [PATCH] [test/Makefile] Auto-generate .gitignore for test executables --- wiringPi/test/Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wiringPi/test/Makefile b/wiringPi/test/Makefile index 299dcb4..151a476 100644 --- a/wiringPi/test/Makefile +++ b/wiringPi/test/Makefile @@ -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