Remove build always regardless of test pass

This commit is contained in:
2025-08-15 15:12:07 -04:00
parent d462f82c8e
commit 4d2cccd385

View File

@@ -11,27 +11,31 @@ SRC := $(wildcard $(SRCDIR)/*.c)
OBJ := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC)) OBJ := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC))
LIB := $(BUILDDIR)/$(LIBNAME).so LIB := $(BUILDDIR)/$(LIBNAME).so
.PHONY: all clean clean-pycache test .PHONY: all clean test
all: $(LIB) all: $(LIB)
$(BUILDDIR): $(BUILDDIR):
@mkdir -p $(BUILDDIR) @mkdir -p $(BUILDDIR)
# compile each .c into build/*.o
$(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR) $(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
$(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
# link shared library
$(LIB): $(OBJ) $(LIB): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(CC) $(LDFLAGS) -o $@ $^
clean: clean:
@echo "Cleaning Python caches..." @echo "Cleaning build and Python caches..."
@rm -rf $(BUILDDIR)
@find . -type d -name "__pycache__" -exec rm -rf {} + @find . -type d -name "__pycache__" -exec rm -rf {} +
@find . -type d -name ".pytest_cache" -exec rm -rf {} + @find . -type d -name ".pytest_cache" -exec rm -rf {} +
@find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete @find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
# run Python unit tests # Always rebuild, and always clean afterward (even if tests fail)
test: all test:
python3 -m unittest -v && $(MAKE) clean @$(MAKE) clean
@$(MAKE) all
@python3 -m unittest -v; \
status=$$?; \
$(MAKE) clean; \
exit $$status