Skip to content

Commit

Permalink
Add automatic compile_commands.json generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gustafla committed Aug 2, 2023
1 parent fdef5f9 commit 5d39647
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ LIBRARIES = $(BUILDDIR)/lib/libSDL2.a $(BUILDDIR)/lib/librocket.a $(BUILDDIR)/in
$(TARGET): $(OBJS)
@mkdir -p $(@D)
$(CC) -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ $(LDLIBS)
ifeq ($(DEBUG),0)
ifeq ($(DEBUG),1)
$(MAKE) compile_commands.json
else
$(STRIP) $(TARGET)
endif

Expand Down Expand Up @@ -81,6 +83,7 @@ $(BUILDDIR)/include/data.c: $(wildcard data/*)
scripts/mkfs.sh > $@


# This generates a compile_commands.json file for clangd, clang-tidy etc. devtools
compile_commands.json: $(SOURCES)
CC=$(CC) CFLAGS="$(CFLAGS) $(EXTRA_CFLAGS)" scripts/gen_compile_commands_json.sh > $@

Expand All @@ -89,6 +92,6 @@ compile_commands.json: $(SOURCES)


clean:
rm -rf $(BUILDDIR) $(RELEASEDIR)
rm -rf $(BUILDDIR) $(RELEASEDIR) compile_commands.json
$(MAKE) -C lib/SDL clean
$(MAKE) -C lib/rocket clean

0 comments on commit 5d39647

Please sign in to comment.