From a5822adfeec556137a97ca00302ddbfeb2c5663f Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 9 Apr 2018 15:57:03 -0400 Subject: [PATCH] Better scan makefiles Signed-off-by: Peter Jones --- .gitignore | 1 + Make.coverity | 41 +++++++++++++++++++++++++++++++++++++++++ Make.defaults | 3 +++ Make.scan-build | 20 ++++++++++++++++++++ Makefile | 28 ++-------------------------- 5 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 Make.coverity create mode 100644 Make.scan-build diff --git a/.gitignore b/.gitignore index 40d17d3..e216036 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ efibootmgr*.zip efibootmgr.spec .*.d cov-int +scan-results/ diff --git a/Make.coverity b/Make.coverity new file mode 100644 index 0000000..ef172b8 --- /dev/null +++ b/Make.coverity @@ -0,0 +1,41 @@ +COV_EMAIL=$(call get-config,coverity.email) +COV_TOKEN=$(call get-config,coverity.token) +COV_URL=$(call get-config,coverity.url) +COV_FILE=$(NAME)-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2 + +cov-int : clean + cov-build --dir cov-int make all + +cov-clean : + @rm -vf $(NAME)-coverity-*.tar.* + @if [[ -d cov-int ]]; then rm -rf cov-int && echo "removed 'cov-int'"; fi + +cov-file : | $(COV_FILE) + +$(COV_FILE) : cov-int + tar caf $@ cov-int + +cov-upload : + @if [[ -n "$(COV_URL)" ]] && \ + [[ -n "$(COV_TOKEN)" ]] && \ + [[ -n "$(COV_EMAIL)" ]] ; \ + then \ + echo curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \ + curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \ + else \ + echo Coverity output is in $(COV_FILE) ; \ + fi + +coverity : | cov-test +coverity : cov-file cov-upload + +clean : | cov-clean + +COV_BUILD ?= $(shell x=$$(which --skip-alias --skip-functions cov-build 2>/dev/null) ; [ -n "$$x" ] && echo 1) +ifeq ($(COV_BUILD),) + COV_BUILD_ERROR = $(error cov-build not found) +endif + +cov-test : ; $(COV_BUILD_ERROR) + +.PHONY : coverity cov-upload cov-clean cov-file cov-test diff --git a/Make.defaults b/Make.defaults index aa6a690..f4f3a9b 100644 --- a/Make.defaults +++ b/Make.defaults @@ -1,3 +1,4 @@ +NAME = efibootmgr prefix ?= /usr libdir ?= $(prefix)/lib64 datadir ?= $(prefix)/share @@ -53,3 +54,5 @@ LDLIBS=$(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs) .PHONY: check_efidir_error check_efidir_error : ; $(EFIDIR_ERROR) $(info Building with EFIDIR as $(EFIDIR)) + +COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master) diff --git a/Make.scan-build b/Make.scan-build new file mode 100644 index 0000000..b3e03ee --- /dev/null +++ b/Make.scan-build @@ -0,0 +1,20 @@ +SCAN_BUILD ?= $(shell x=$$(which --skip-alias --skip-functions scan-build 2>/dev/null) ; [ -n "$$x" ] && echo 1) +ifeq ($(SCAN_BUILD),) + SCAN_BUILD_ERROR = $(error scan-build not found) +endif + +scan-test : ; $(SCAN_BUILD_ERROR) + +scan-clean : clean + @if [[ -d scan-results ]]; then rm -rf scan-results && echo "removed 'scan-results'"; fi + +scan-build : | scan-test +scan-build : clean + scan-build -o scan-results make $(DASHJ) CC=clang all + +scan-build-all : | scan-test +scan-build-all : clean + scan-build -o scan-results make $(DASHJ) CC=clang all + +.PHONY : scan-build scan-clean + diff --git a/Makefile b/Makefile index 8383eee..00b8cdd 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ TOPDIR = $(shell echo $$PWD) include $(TOPDIR)/Make.version include $(TOPDIR)/Make.rules include $(TOPDIR)/Make.defaults +include $(TOPDIR)/Make.coverity +include $(TOPDIR)/Make.scan-build SUBDIRS := src @@ -15,7 +17,6 @@ clean : | check_efidir_error Make.version @set -e ; for x in $(SUBDIRS) ; do \ $(MAKE) -C $$x $@ ; \ done - @rm -rvf cov-int efibootmgr-coverity-*.tar.* all : efibootmgr.spec @@ -33,31 +34,6 @@ distclean : $(MAKE) clean @rm -vf efibootmgr.spec -COV_EMAIL=$(call get-config,coverity.email) -COV_TOKEN=$(call get-config,coverity.token) -COV_URL=$(call get-config,coverity.url) -COV_FILE=efibootmgr-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2 -COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master) - -cov-int : clean - cov-build --dir cov-int make all - -$(COV_FILE) : cov-int - tar caf $@ cov-int - -cov-upload : - @if [[ -n "$(COV_URL)" ]] && \ - [[ -n "$(COV_TOKEN)" ]] && \ - [[ -n "$(COV_EMAIL)" ]] ; \ - then \ - echo curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \ - curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \ - else \ - echo Coverity output is in $(COV_FILE) ; \ - fi - -coverity : $(COV_FILE) cov-upload - GITTAG = $(VERSION) test-archive: efibootmgr.spec -- 2.11.0