summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-10-30 22:49:38 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-31 18:43:46 +0000
commit9fd4258f365c6c74114c34dbe56e85819a585208 (patch)
tree57a4c364492696d0a2cbf4d65c97c68e3171d161
parent2dc1418ccdad1b06f686cddc717e02bcb80ff648 (diff)
downloadchrome-ec-9fd4258f365c6c74114c34dbe56e85819a585208.tar.gz
Replace Makefile 'tags' target with 'xrefs', clean it up
This adds a 'xrefs' target to create various cross-reference files from the EC sources. In particular, it generates these files in the target build directory: cscope.files - for the cscope browsing tool TAGS - for emacs tags - for vi It parses the dependency files generated by a build, so that only those source files actually used to create the EC binary are scanned. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual Inside the chroot: make BOARD=link xrefs ls -l build/link/cscope.files If you install the ctags and etags programs in the chroot, you should also see build/$BOARD/tags or build/$BOARD/TAGS, respectively. If those programs don't exist, those steps will be silently skipped. Note: You can install ctags with "sudo emerge ctags". AFAICT, installing etags requires the entire emacs suite, so it's probably simpler to just copy the etags binary from your build host into the chroot's /opt/bin/ If you don't have ctags or etags in the chroot, you can still run make BOARD=link CROSS_COMPILE= xrefs outside the chroot, provided you've built the EC image first. Change-Id: I8e16ef19b0f4e79aba887c308e58982fef8fa21f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/175224
-rw-r--r--Makefile.rules27
1 files changed, 18 insertions, 9 deletions
diff --git a/Makefile.rules b/Makefile.rules
index c72a229f3f..6360edcf3b 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -47,6 +47,13 @@ cmd_extractrw-y = cd $(out) && \
mv RW_SECTION_A $(PROJECT).RW.bin
cmd_copyrw-y = cd $(out) && cp $(PROJECT).RW.flat $(PROJECT).RW.bin
+# commands to build optional xref files
+cmd_deps_to_list = cat $(deps) | tr -d ':\\' | tr ' ' '\012' \
+ | egrep '\.[chS]$$' | sort | uniq > $@
+cmd_etags = etags -o $@ $(shell cat $<)
+cmd_ctags = ctags -o $@ $(shell cat $<)
+targ_if_prog = $(if $(shell which $(1) 2>/dev/null),$(2),)
+
.PHONY: all tests utils hosttests
all: $(out)/$(PROJECT).bin utils
@@ -155,16 +162,18 @@ $(host-utils): $(out)/%:%.c $(foreach u,$(host-util-common),util/$(u).c) \
$(out)/util/burn_my_ec: $(out)/$(PROJECT).bin
-.PHONY: FORCE
-cscope.files: FORCE
- @-rm -f cscope.out
- @find chip/${CHIP} board/${BOARD} common core driver power include \
- -name '*.[chS]' \
- -not -name '*test*' -not -name '*mock*' -not -name '*~*' \
- > cscope.files
+$(out)/cscope.files: $(out)/$(PROJECT).bin
+ $(call quiet,deps_to_list,SH )
+
+$(out)/TAGS: $(out)/cscope.files
+ $(call quiet,etags,ETAGS )
+
+$(out)/tags: $(out)/cscope.files
+ $(call quiet,ctags,CTAGS )
-TAGS tags: cscope.files
- @etags $(shell cat cscope.files)
+.PHONY: xrefs
+xrefs: $(call targ_if_prog,etags,$(out)/TAGS) \
+ $(call targ_if_prog,ctags,$(out)/tags)
.PHONY: clean
clean: