aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-06-18 21:27:24 +0200
committerBad Diode <bd@badd10de.dev>2024-06-18 21:27:24 +0200
commitad14773fcebdbd989c1d7c3245b59a1cae666d2f (patch)
treea7eb2ceebfc7c89fd04a143d535b5701de5bfa98 /Makefile
parent3d88e46dd0d1b54bc0a414b5db42ed76ddc08363 (diff)
downloadbdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.tar.gz
bdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.zip
Add `tests` target to makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile28
1 files changed, 18 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index b6419fd..5af466c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,10 @@
4# Source code location and files to watch for changes. 4# Source code location and files to watch for changes.
5SRC_DIR := src 5SRC_DIR := src
6BUILD_DIR := build 6BUILD_DIR := build
7TESTS_DIR := tests
8TEST_FILES := $(wildcard $(TESTS_DIR)/*.bad)
7SRC_MAIN := $(SRC_DIR)/main.c 9SRC_MAIN := $(SRC_DIR)/main.c
8SRC_BAD := tests/conditionals.bad 10SRC_RUN := tests/conditionals.bad
9WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") 11WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h")
10INC_DIRS := $(shell find $(SRC_DIR) -type d) 12INC_DIRS := $(shell find $(SRC_DIR) -type d)
11INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 13INC_FLAGS := $(addprefix -I,$(INC_DIRS))
@@ -45,7 +47,7 @@ endif
45 47
46main: $(BIN) 48main: $(BIN)
47 49
48$(BIN): $(SRC_MAIN) $(WATCH_SRC) $(BUILD_DIR) 50$(BIN): $(SRC_MAIN) $(WATCH_SRC) | $(BUILD_DIR)
49 $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(SRC_MAIN) $(LDLIBS) 51 $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(SRC_MAIN) $(LDLIBS)
50 52
51# Create build directory if needed. 53# Create build directory if needed.
@@ -53,22 +55,28 @@ $(BUILD_DIR):
53 mkdir -p $(BUILD_DIR) 55 mkdir -p $(BUILD_DIR)
54 56
55run: $(BIN) 57run: $(BIN)
56 $(BIN) $(SRC_BAD) 58 $(BIN) $(SRC_RUN)
57 59
58graph-tokens: $(BIN) 60graph-tokens: $(BIN)
59 $(BIN) -pl $(SRC_BAD) 61 $(BIN) -pl $(SRC_RUN)
60 62
61graph-parse: $(BIN) 63graph-parse: $(BIN)
62 @echo "parsing tree for: '$(SRC_BAD)'" 64 @echo "parsing tree for: '$(SRC_RUN)'"
63 @$(BIN) -pp $(SRC_BAD) | $(DOT) 65 @$(BIN) -pp $(SRC_RUN) | $(DOT)
64 66
65graph-semantic: $(BIN) 67graph-semantic: $(BIN)
66 @echo "semantic tree for: '$(SRC_BAD)'" 68 @echo "semantic tree for: '$(SRC_RUN)'"
67 @$(BIN) -ps $(SRC_BAD) | $(DOT) 69 @$(BIN) -ps $(SRC_RUN) | $(DOT)
68 70
69graph-symbols: $(BIN) 71graph-symbols: $(BIN)
70 @echo "symbol table for: '$(SRC_BAD)'" 72 @echo "symbol table for: '$(SRC_RUN)'"
71 @$(BIN) -pt $(SRC_BAD) | $(DOT) 73 @$(BIN) -pt $(SRC_RUN) | $(DOT)
74
75tests: $(BIN)
76 @for name in $(TEST_FILES); do\
77 printf "$${name}\r" ;\
78 $(BIN) $${name} && printf "$${name}\tOK!\n";\
79 done
72 80
73# Remove build directory. 81# Remove build directory.
74clean: 82clean: