[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.
This commit is contained in:
BuFran 2013-07-07 15:16:57 +02:00 committed by Piotr Esden-Tempski
parent 7002bca027
commit b8e8cb2f0d
1 changed files with 20 additions and 8 deletions

View File

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