Add fen loader and a test script for c
All checks were successful
Python tests (make) / test (push) Successful in 10s
Python tests (make) / test (pull_request) Successful in 9s

This commit is contained in:
2025-08-16 12:44:04 -04:00
parent db11521329
commit c80826710d
6 changed files with 103 additions and 6 deletions

View File

@@ -7,11 +7,17 @@ INCDIR := engine/include
BUILDDIR := build
LIBNAME := libchess
SRC := $(wildcard $(SRCDIR)/*.c)
# Exclude test.c from the shared lib build
SRC := $(filter-out $(SRCDIR)/test.c,$(wildcard $(SRCDIR)/*.c))
OBJ := $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/%.o,$(SRC))
LIB := $(BUILDDIR)/$(LIBNAME).so
.PHONY: all clean test
# ---- test executable (engine/src/test.c) ----
TESTSRC := $(SRCDIR)/test.c
TESTOBJ := $(BUILDDIR)/test.o
TESTBIN := $(BUILDDIR)/print_board
.PHONY: all clean test test-exe run
all: $(LIB)
@@ -24,6 +30,17 @@ $(BUILDDIR)/%.o: $(SRCDIR)/%.c | $(BUILDDIR)
$(LIB): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^
c-test-exe: $(TESTBIN)
$(TESTOBJ): $(TESTSRC) | $(BUILDDIR)
$(CC) -std=c11 -Wall -Wextra -O2 -I$(INCDIR) -c $< -o $@
$(TESTBIN): $(TESTOBJ) $(LIB)
$(CC) -O2 -o $@ $(TESTOBJ) -L$(BUILDDIR) -lchess -Wl,-rpath,'$$ORIGIN'
run-c-test: test-exe
LD_LIBRARY_PATH=$(BUILDDIR) $(TESTBIN) $(FEN)
clean:
@echo "Cleaning build and Python caches..."
@rm -rf $(BUILDDIR)
@@ -31,7 +48,6 @@ clean:
@find . -type d -name ".pytest_cache" -exec rm -rf {} +
@find . -type f \( -name "*.pyc" -o -name "*.pyo" \) -delete
# Always rebuild, and always clean afterward (even if tests fail)
test:
@$(MAKE) clean
@$(MAKE) all