Blob Blame History Raw
From d27930abbc6af501d8375b1a28001691b91fc952 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 9 May 2017 11:35:17 -0400
Subject: [PATCH 13/13] Add coverity makefile bits

This lets us do semi-automated coverity uploads directly from the repo
checkout.

Signed-off-by: Peter Jones <pjones@redhat.com>
---
 .gitignore |  1 +
 Make.rules |  6 ++++++
 Makefile   | 38 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 Make.rules

diff --git a/.gitignore b/.gitignore
index 25be91f..91c3ae6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
 *.tar.*
 .*.sw?
 linux/include/fwup-version.h
+cov-int
diff --git a/Make.rules b/Make.rules
new file mode 100644
index 0000000..b7cd9e8
--- /dev/null
+++ b/Make.rules
@@ -0,0 +1,6 @@
+
+include $(TOPDIR)/Make.version
+
+define get-config
+$(shell git config --local --get "fwupdate.$(1)")
+endef
diff --git a/Makefile b/Makefile
index 6d6511b..14c3ad6 100644
--- a/Makefile
+++ b/Makefile
@@ -2,10 +2,11 @@ default : all
 
 TOPDIR=$(shell pwd)
 include $(TOPDIR)/Make.version
+include $(TOPDIR)/Make.rules
 include $(TOPDIR)/Make.defaults
 SUBDIRS ?= efi linux docs include
 
-all clean install : | check_efidir_error
+all install : | check_efidir_error
 	@set -e ; for x in $(SUBDIRS) ; do \
 		$(MAKE) DESTDIR=$(DESTDIR) TOPDIR=$(TOPDIR) VERSION=$(VERSION) \
 			LIBDIR=$(LIBDIR) bindir=$(bindir) mandir=$(mandir) \
@@ -15,6 +16,39 @@ all clean install : | check_efidir_error
 fwupdate.spec : fwupdate.spec.in Makefile
 	@sed -e "s,@@VERSION@@,$(VERSION),g" $< > $@
 
+COV_EMAIL=$(call get-config,coverity.email)
+COV_TOKEN=$(call get-config,coverity.token)
+COV_URL=$(call get-config,coverity.url)
+COV_FILE=fwupdate-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2
+COMMIT_ID=$(shell git log -1 --pretty=%H 2>/dev/null || echo master)
+
+clean :
+	@set -e ; for x in $(SUBDIRS) ; do \
+		$(MAKE) DESTDIR=$(DESTDIR) TOPDIR=$(TOPDIR) VERSION=$(VERSION) \
+			LIBDIR=$(LIBDIR) bindir=$(bindir) mandir=$(mandir) \
+			-C $$x $@ ; \
+	done
+	@rm -vrf cov-int fwupdate-coverity-*.tar.*
+
+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: fwupdate.spec
@@ -40,3 +74,5 @@ archive: tag fwupdate.spec
 	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/fwupdate-$(VERSION).tar.bz2 fwupdate-$(VERSION)
 	@rm -rf /tmp/fwupdate-$(VERSION)
 	@echo "The archive is in fwupdate-$(VERSION).tar.bz2"
+
+.PHONY: $(SUBDIRS) coverity cov-upload
-- 
2.12.2