diff options
author | Travis Geiselbrecht <geist@foobox.com> | 2024-05-09 20:27:54 -0700 |
---|---|---|
committer | Travis Geiselbrecht <geist@foobox.com> | 2024-05-09 20:29:08 -0700 |
commit | 5d8dd9c36ae811f72b9aade36f5900beb7533599 (patch) | |
tree | e304ac68d09ded7ea283ce77316262db441fd743 | |
parent | 60bee016210bba0d5b0ebd9c4f05f11176006137 (diff) | |
download | lk-5d8dd9c36ae811f72b9aade36f5900beb7533599.tar.gz |
[make] add 'make tags'
Tries to generate a curated ctags file for the current project and
configuration.
-rw-r--r-- | engine.mk | 6 | ||||
-rw-r--r-- | make/build.mk | 14 | ||||
-rw-r--r-- | make/help.mk | 1 |
3 files changed, 18 insertions, 3 deletions
@@ -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: diff --git a/make/build.mk b/make/build.mk index 814dccc8..90bcdc8b 100644 --- a/make/build.mk +++ b/make/build.mk @@ -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' > $@ diff --git a/make/help.mk b/make/help.mk index c71ab3b3..a389bf3c 100644 --- a/make/help.mk +++ b/make/help.mk @@ -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" |