blob: c32deef37214db91b2a36bd5787b0f5c3fd40ffb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
.PHONY: all queries tsbuild valgrind tests format clean
TARGET = crep
SOURCES = $(wildcard *.c *.h)
TS_ALIBS = $(shell find vendor -name "*.a" -print)
VENDOR_DIRS = $(wildcard vendor/*)
CFLAGS = $(EXTRA_FLAGS) -Wall -Wextra -std=gnu99 -pedantic -O3
LIBS = -I./vendor/tree-sitter/lib/include -lpthread
LANGS = c cpp python php go rust javascript lua zig
QUERY_HEADERS = $(patsubst %, queries/%.h, $(LANGS))
TS_SUBDIRS = tree-sitter $(patsubst %, tree-sitter-%, $(LANGS))
$(info VENDOR_DIRS: $(VENDOR_DIRS))
$(info LANGS: $(LANGS))
$(info QUERY_HEADERS: $(QUERY_HEADERS))
$(info TS_SUBDIRS: $(TS_SUBDIRS))
$(info SOURCES: $(SOURCES))
$(info TS_ALIBS: $(TS_ALIBS))
$(info CFLAGS: $(CFLAGS))
$(info LIBS: $(LIBS))
all: $(QUERY_HEADERS) tsbuild $(TARGET)
tsbuild:
$(MAKE) -C vendor/tree-sitter libtree-sitter.a
@for lang in $(LANGS); do \
$(MAKE) -C vendor/tree-sitter-$$lang libtree-sitter-$$lang.a || true; \
done
$(TARGET): $(SOURCES) tsbuild
$(CC) $(CFLAGS) $(SOURCES) $(LIBS) -o $(TARGET) $(shell find vendor -name "*.a")
queries/%.h: queries/%.scm
xxd -i -n query_$* $< > $@
queries: $(QUERY_HEADERS)
valgrind:
valgrind -s --leak-check=full ./$(TARGET)
tests: $(TARGET)
sh tests.sh
format:
clang-format -i *.c *.h
clean:
rm -f *.o $(TARGET) callgrind.out.* queries/*.h
@for dir in $(TS_SUBDIRS); do \
$(MAKE) -C vendor/$$dir clean; \
done
|