Remove build always regardless of test pass
This commit is contained in:
18
makefile
18
makefile
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user