Skip to content

Commit

Permalink
[make] add 'make tags'
Browse files Browse the repository at this point in the history
Tries to generate a curated ctags file for the current project and
configuration.
  • Loading branch information
travisg committed May 10, 2024
1 parent 60bee01 commit 5d8dd9c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion engine.mk
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ list-arch:
list-toolchain:
@echo TOOLCHAIN_PREFIX = ${TOOLCHAIN_PREFIX}

.PHONY: all clean install list-arch list-toolchain
tags: $(BUILDDIR)/srcfiles.txt $(BUILDDIR)/include_paths.txt
$(info generating tags)
@ctags -L $<

.PHONY: all clean install list-arch list-toolchain tags

# generate a config.h file with all of the GLOBAL_DEFINES laid out in #define format
configheader:
Expand Down
14 changes: 12 additions & 2 deletions make/build.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Rules for generating the final binary and any auxillary files generated as a result.

# use linker garbage collection, if requested
WITH_LINKER_GC ?= false
ifeq (true,$(call TOBOOL,$(WITH_LINKER_GC)))
Expand Down Expand Up @@ -58,12 +60,20 @@ $(OUTELF).size: $(OUTELF)
$(NOECHO)$(NM) -S --size-sort $< | $(CPPFILT) > $@
$(NOECHO)echo "# vim: ts=8 nolist nowrap" >> $@

# print some information about the build
$(BUILDDIR)/srcfiles.txt: $(OUTELF)
# generate a list of source files that potentially participate in this build.
# header file detection is a bit sloppy: it simply searches for every .h file inside
# the combined include paths. May pick up files that are not strictly speaking used.
# Alternate strategy that may work: union all of the .d files together and collect all
# of the used headers used there.
$(BUILDDIR)/srcfiles.txt: $(OUTELF) $(BUILDDIR)/include_paths.txt
@$(MKDIR)
$(info generating $@)
$(NOECHO)echo $(sort $(ALLSRCS)) | tr ' ' '\n' > $@
@for i in `cat $(BUILDDIR)/include_paths.txt`; do if [ -d $$i ]; then find $$i -type f -name \*.h; fi; done >> $@

# generate a list of all the include directories used in this project
$(BUILDDIR)/include_paths.txt: $(OUTELF)
@$(MKDIR)
$(info generating $@)
$(NOECHO)echo $(subst -I,,$(sort $(GLOBAL_INCLUDES))) | tr ' ' '\n' > $@

Expand Down
1 change: 1 addition & 0 deletions make/help.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ help:
@echo "make list: List of buildable projects"
@echo "make clean: cleans build of current project"
@echo "make spotless: removes all build directories"
@echo "make tags: run ctags on all of the source files for the current project"
@echo "make <project>: try to build project named <project>"
@echo ""
@echo "make list-arch: print the architecture of the current project"
Expand Down

0 comments on commit 5d8dd9c

Please sign in to comment.