From b8e8cb2f0d3e8b29b026906a6713795aafcbf3ee Mon Sep 17 00:00:00 2001 From: BuFran Date: Sun, 7 Jul 2013 15:16:57 +0200 Subject: [PATCH] [BUILD] Paralelize stylecheck Each thread runs its own stylecheck script, outputing to {FILENAME}.stylecheck file. If that file is empty, it is deleted. Otherwise it is printed to the output and stays in the sources directory to indicate something in that file is not correct. The file mangling and cat-ing is needed because of multithreaded nature of paralell make. (We like single file to be an block of text on the output). New PHONY added that make styleclean clears all .stylecheck files. New functionality added to check only single file (specifyilng the file with stylecheck extension) ie make lib/usb/usb.c.stylecheck BUG: if someone edit that file, .stylecheck file is not regenerated - missing dependency on the %.stylecheck rule. FIX: make styleclean stylecheck rebuild all style errors Performance: make stylecheck 1:43 -> 1:54 (slightly slower due to file creation) make stylecheck -j8 1:43 -> 0:34 (Rapidly faster) note the -j option must be specified with number, OS Windows cannot handle one thread per file. --- Makefile | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9affd9e4..1531d7af 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ MAKEFLAGS += --no-print-directory endif YAMLFILES := $(shell find . -name 'irq.yaml') +STYLECHECKFILES := $(shell find . -name '*.[ch]') all: build @@ -88,7 +89,7 @@ install: lib doc: $(Q)$(MAKE) -C doc html -clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean +clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean styleclean %.clean: $(Q)if [ -d $* ]; then \ @@ -96,12 +97,23 @@ clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.c $(MAKE) -C $* clean SRCLIBDIR=$(SRCLIBDIR) || exit $?; \ fi; -stylecheck: - $(Q)for i in `find . -name '*.[ch]'` ; do \ - if ! grep -q "* It was generated by the irq2nvic_h script." $$i ; then \ - $(STYLECHECK) $(STYLECHECKFLAGS) $$i; \ - fi ; \ - done -.PHONY: build lib $(LIB_DIRS) install doc clean stylecheck +stylecheck: $(STYLECHECKFILES:=.stylecheck) +styleclean: $(STYLECHECKFILES:=.styleclean) + +# the cat is due to multithreaded nature - we like to have consistent chunks of text on the output +%.stylecheck: + $(Q)if ! grep -q "* It was generated by the irq2nvic_h script." $* ; then \ + $(STYLECHECK) $(STYLECHECKFLAGS) $* > $*.stylecheck; \ + if [ -s $*.stylecheck ]; then \ + cat $*.stylecheck; \ + else \ + rm -f $*.stylecheck; \ + fi; \ + fi; + +%.styleclean: + $(Q)rm -f $*.stylecheck; + +.PHONY: build lib $(LIB_DIRS) install doc clean stylecheck styleclean