add-piece-move-cache (#1)

Reviewed-on: #1
Co-authored-by: Josh <josh@joshuaschuett.com>
Co-committed-by: Josh <josh@joshuaschuett.com>
This commit is contained in:
2025-08-10 19:39:18 +00:00
committed by Josh
parent da31f8b6fe
commit 3ba72c0bc3
8 changed files with 322 additions and 1 deletions

46
makefile Normal file
View File

@@ -0,0 +1,46 @@
# Makefile at project root
CC := gcc
CFLAGS := -O3 -fPIC -Wall -Wextra
LDFLAGS := -shared
SRCDIR := engine/src
INCDIR := engine/include
BUILDDIR := build
LIBNAME := libchess
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SOEXT := dylib
else
SOEXT := so
endif
SRC := $(wildcard $(SRCDIR)/*.c)
OBJ := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC))
LIB := $(BUILDDIR)/$(LIBNAME).$(SOEXT)
.PHONY: all clean clean-pycache test
all: $(LIB)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
# compile each .c into build/*.o
$(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
$(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@
# link shared library
$(LIB): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^
clean:
@echo "Cleaning Python caches..."
@find . -type d -name "__pycache__" -exec rm -rf {} +
@find . -type d -name ".pytest_cache" -exec rm -rf {} +
@find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
# run Python unit tests
test: all
python3 -m unittest -v && $(MAKE) clean