[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] build: correct cppcheck-misra make rule


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 12 Sep 2022 08:46:31 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NbFs4FLfoe7rY9uiZUQIJxZ8jXRz6b8XdHmvqPqvCOE=; b=e7qseqA/a5TzRTAaIvkTjDIdPHWD5cSWsDQGWerL+WDWSrKuNDH5B2M8r9hGqQwtnzzkSCMgl/KF0Ewcw15TELULmfFEJ2NzsadzSQZ70bVx23z5bey1GCqkHRF2+6f9gjAzkaB4uJzDS/lM5BL48yXGdKCnWAWOgo9o2Dsq2A+gA0bkT5RngezTOKORFf2GKq0k7wSxYFdweE/kGVDJGsIxXpuzdwUdke23+Ya0kGHgd4jLX2E+Onl7Af2jFeo0z+Q+hddla+BBI6rdgLSrMaE5otc18H5kB2Ik+iqBkb10M7qjTwp/cjVjiyVWpt3WlCR/c9oRybx8FsZp5QxwJw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AMq6+CkqdrAr42k5XudWqiAX90MYDbd32ZXKkzPiPyj3F2th+Mn0XknOH0sIbelcq/n24vwMDn2gJpk6bW5ushYuNVMvzUek9dB1y1gU8ZOljYaBborVHNFhorMRFJAyUzdrtKuUFJlBF5bvAtWP/HbFQ+MOevc6ioq8JOu7bt0l3CeIBdDVOVHTQrUb2c046S+mjQceewejGMKso8WrSOw3OJA7A7vWUJZZpW6CAiqcfxVPgn1nBVRfLEResueJySAFTRFf7Nw/EZ4FWpmb68sgGc0S1dVA3FTl0MjcTNXBaswWSU9poAI0razOnai27aEKaU4o87/7sCXMDuxyhQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Mon, 12 Sep 2022 06:46:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Having cppcheck-misra.json depend on cppcheck-misra.txt does not
properly address the multiple targets problem. If cppcheck-misra.json
is deleted from the build tree but cppcheck-misra.txt is still there,
nothing will re-generate cppcheck-misra.json.

With GNU make 4.3 or newer we could use the &: grouped target separator,
but since we support older make as well we need to use some other
mechanism. Convert the rule to a pattern one (with "cppcheck" kind of
arbitrarily chosen as the stem), thus making known to make that both
files are created by a single command invocation. Since, as a result,
the JSON file is now "intermediate" from make's perspective, prevent it
being deleted again by making it a prereq of .PRECIOUS.

Fixes: 57caa5375321 ("xen: Add MISRA support to cppcheck make rule")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Add comment. Add Fixes: tag.
---
It has been bothering me for a while that I made a bad suggestion during
review; I'm sorry for that.

--- a/xen/Makefile
+++ b/xen/Makefile
@@ -746,11 +746,12 @@ cppcheck-version:
 # documentation file. Also generate a json file with the right arguments for
 # cppcheck in json format including the list of rules to ignore.
 #
-cppcheck-misra.txt: $(XEN_ROOT)/docs/misra/rules.rst 
$(srctree)/tools/convert_misra_doc.py
-       $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o $@ -j 
$(@:.txt=.json)
-
-# convert_misra_doc is generating both files.
-cppcheck-misra.json: cppcheck-misra.txt
+# convert_misra_doc.py, producing both targets at the same time, should be
+# executed only once. Utilize a pattern rule to achieve this effect, with the
+# stem kind of arbitrarily chosen to be "cppcheck".
+.PRECIOUS: %-misra.json
+%-misra.txt %-misra.json: $(XEN_ROOT)/docs/misra/rules.rst 
$(srctree)/tools/convert_misra_doc.py
+       $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o 
$*-misra.txt -j $*-misra.json
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.