diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-18 21:27:24 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-18 21:27:24 +0200 |
commit | ad14773fcebdbd989c1d7c3245b59a1cae666d2f (patch) | |
tree | a7eb2ceebfc7c89fd04a143d535b5701de5bfa98 /Makefile | |
parent | 3d88e46dd0d1b54bc0a414b5db42ed76ddc08363 (diff) | |
download | bdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.tar.gz bdl-ad14773fcebdbd989c1d7c3245b59a1cae666d2f.zip |
Add `tests` target to makefile
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -4,8 +4,10 @@ | |||
4 | # Source code location and files to watch for changes. | 4 | # Source code location and files to watch for changes. |
5 | SRC_DIR := src | 5 | SRC_DIR := src |
6 | BUILD_DIR := build | 6 | BUILD_DIR := build |
7 | TESTS_DIR := tests | ||
8 | TEST_FILES := $(wildcard $(TESTS_DIR)/*.bad) | ||
7 | SRC_MAIN := $(SRC_DIR)/main.c | 9 | SRC_MAIN := $(SRC_DIR)/main.c |
8 | SRC_BAD := tests/conditionals.bad | 10 | SRC_RUN := tests/conditionals.bad |
9 | WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") | 11 | WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") |
10 | INC_DIRS := $(shell find $(SRC_DIR) -type d) | 12 | INC_DIRS := $(shell find $(SRC_DIR) -type d) |
11 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) | 13 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) |
@@ -45,7 +47,7 @@ endif | |||
45 | 47 | ||
46 | main: $(BIN) | 48 | main: $(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 | ||
55 | run: $(BIN) | 57 | run: $(BIN) |
56 | $(BIN) $(SRC_BAD) | 58 | $(BIN) $(SRC_RUN) |
57 | 59 | ||
58 | graph-tokens: $(BIN) | 60 | graph-tokens: $(BIN) |
59 | $(BIN) -pl $(SRC_BAD) | 61 | $(BIN) -pl $(SRC_RUN) |
60 | 62 | ||
61 | graph-parse: $(BIN) | 63 | graph-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 | ||
65 | graph-semantic: $(BIN) | 67 | graph-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 | ||
69 | graph-symbols: $(BIN) | 71 | graph-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 | |||
75 | tests: $(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. |
74 | clean: | 82 | clean: |