Add fen loader and a test script for c
This commit is contained in:
22
makefile
22
makefile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user