[make] add 'make tags'

Tries to generate a curated ctags file for the current project and
configuration.
This commit is contained in:
Travis Geiselbrecht
2024-05-09 20:27:54 -07:00
parent 60bee01621
commit 5d8dd9c36a
3 changed files with 18 additions and 3 deletions

View File

@@ -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:

View File

@@ -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)))
@@ -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' > $@

View File

@@ -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"