Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/107454/?format=api
http://patches.dpdk.org/api/patches/107454/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20220214113632.3184921-2-sean.morrissey@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20220214113632.3184921-2-sean.morrissey@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20220214113632.3184921-2-sean.morrissey@intel.com", "date": "2022-02-14T11:35:43", "name": "[v7,01/50] devtools: script to remove unused headers includes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "02b0f5243cad7e6c8f19a6ba3c9114b8ff0d98fa", "submitter": { "id": 1359, "url": "http://patches.dpdk.org/api/people/1359/?format=api", "name": "Sean Morrissey", "email": "sean.morrissey@intel.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20220214113632.3184921-2-sean.morrissey@intel.com/mbox/", "series": [ { "id": 21658, "url": "http://patches.dpdk.org/api/series/21658/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=21658", "date": "2022-02-14T11:35:42", "name": "introduce IWYU", "version": 7, "mbox": "http://patches.dpdk.org/series/21658/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/107454/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/107454/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 17545A034C;\n\tMon, 14 Feb 2022 12:37:06 +0100 (CET)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 11B94410F3;\n\tMon, 14 Feb 2022 12:37:04 +0100 (CET)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by mails.dpdk.org (Postfix) with ESMTP id ED72B4067E\n for <dev@dpdk.org>; Mon, 14 Feb 2022 12:37:00 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 14 Feb 2022 03:37:00 -0800", "from silpixa00401215.ir.intel.com ([10.55.128.96])\n by fmsmga002.fm.intel.com with ESMTP; 14 Feb 2022 03:36:58 -0800" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1644838621; x=1676374621;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=pjX+mx97VoeEUCRAGvzhtBBr34EDSL09KhLFuikBuwg=;\n b=kYv3V0XmpasUD3XfG9sLfd+HM57VmtCX5oVWH18sVUEG2zUb3fDqhTNA\n izcaUtH3mbEyWmiXV1o9p6cLV/N5JobwWfqXKDQpz4eBPoZoLQ3Ax8jGR\n 9Sd4mZH6BHKw3469XIs4m1Mmq+qqFkasBxmSbTBTzZ+IewzaL9MdebtVY\n hdkzGM8BsEVavIzgKe8BlTPbxrelwFQg/QCptjsodghtBZmGhq6ukzzwf\n y1IWEdR70Maf7Ji56IKVaSuZzyXItT98Jdsx6aoxEXlC+CJpJGGGthlnH\n vx1yyarEdT4B+8jlBUjm++apQn1vFQ8d+1AG+df9ktqYtPTMHxb6ZfFwv w==;", "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10257\"; a=\"233619803\"", "E=Sophos;i=\"5.88,367,1635231600\"; d=\"scan'208\";a=\"233619803\"", "E=Sophos;i=\"5.88,367,1635231600\"; d=\"scan'208\";a=\"632086854\"" ], "X-ExtLoop1": "1", "From": "Sean Morrissey <sean.morrissey@intel.com>", "To": "", "Cc": "dev@dpdk.org, Sean Morrissey <sean.morrissey@intel.com>,\n Conor Fogarty <conor.fogarty@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>", "Subject": "[PATCH v7 01/50] devtools: script to remove unused headers includes", "Date": "Mon, 14 Feb 2022 11:35:43 +0000", "Message-Id": "<20220214113632.3184921-2-sean.morrissey@intel.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220214113632.3184921-1-sean.morrissey@intel.com>", "References": "<20220202094802.3618978-1-sean.morrissey@intel.com>\n <20220214113632.3184921-1-sean.morrissey@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "This script can be used for removing headers flagged for removal by the\ninclude-what-you-use (IWYU) tool. The script has the ability to remove\nheaders from specified sub-directories or dpdk as a whole and tests the\nbuild after each removal by calling meson compile.\n\nexample usages:\n\nRemove headers flagged by iwyu_tool output file\n$ ./devtools/process_iwyu.py iwyu.out -b build\n\nRemove headers flagged by iwyu_tool output file from sub-directory\n$ ./devtools/process_iwyu.py iwyu.out -b build -d lib/kvargs\n\nRemove headers directly piped from the iwyu_tool\n$ iwyu_tool -p build | ./devtools/process_iwyu.py - -b build\n\nSigned-off-by: Sean Morrissey <sean.morrissey@intel.com>\nSigned-off-by: Conor Fogarty <conor.fogarty@intel.com>\nReviewed-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n devtools/process_iwyu.py | 109 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 109 insertions(+)\n create mode 100755 devtools/process_iwyu.py", "diff": "diff --git a/devtools/process_iwyu.py b/devtools/process_iwyu.py\nnew file mode 100755\nindex 0000000000..50f3d4c5c7\n--- /dev/null\n+++ b/devtools/process_iwyu.py\n@@ -0,0 +1,109 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2021 Intel Corporation\n+#\n+\n+import argparse\n+import fileinput\n+import sys\n+from os.path import abspath, relpath, join\n+from pathlib import Path\n+from mesonbuild import mesonmain\n+\n+\n+def args_parse():\n+ \"parse arguments and return the argument object back to main\"\n+ parser = argparse.ArgumentParser(description=\"This script can be used to remove includes which are not in use\\n\")\n+ parser.add_argument('-b', '--build_dir', type=str, default='build',\n+ help=\"The path to the build directory in which the IWYU tool was used in.\")\n+ parser.add_argument('-d', '--sub_dir', type=str, default='',\n+ help=\"The sub-directory to remove headers from.\")\n+ parser.add_argument('file', type=Path,\n+ help=\"The path to the IWYU log file or output from stdin.\")\n+\n+ return parser.parse_args()\n+\n+\n+def run_meson(args):\n+ \"Runs a meson command logging output to process.log\"\n+ with open('process_iwyu.log', 'a') as sys.stdout:\n+ ret = mesonmain.run(args, abspath('meson'))\n+ sys.stdout = sys.__stdout__\n+ return ret\n+\n+\n+def remove_includes(filepath, include, build_dir):\n+ \"Attempts to remove include, if it fails then revert to original state\"\n+ with open(filepath) as f:\n+ lines = f.readlines() # Read lines when file is opened\n+\n+ with open(filepath, 'w') as f:\n+ for ln in lines: # Removes the include passed in\n+ if not ln.startswith(include):\n+ f.write(ln)\n+\n+ # run test build -> call meson on the build folder, meson compile -C build\n+ ret = run_meson(['compile', '-C', build_dir])\n+ if (ret == 0): # Include is not needed -> build is successful\n+ print('SUCCESS')\n+ else:\n+ # failed, catch the error\n+ # return file to original state\n+ with open(filepath, 'w') as f:\n+ f.writelines(lines)\n+ print('FAILED')\n+\n+\n+def get_build_config(builddir, condition):\n+ \"returns contents of rte_build_config.h\"\n+ with open(join(builddir, 'rte_build_config.h')) as f:\n+ return [ln for ln in f.readlines() if condition(ln)]\n+\n+\n+def uses_libbsd(builddir):\n+ \"return whether the build uses libbsd or not\"\n+ return bool(get_build_config(builddir, lambda ln: 'RTE_USE_LIBBSD' in ln))\n+\n+\n+def process(args):\n+ \"process the iwyu output on a set of files\"\n+ filepath = None\n+ build_dir = abspath(args.build_dir)\n+ directory = args.sub_dir\n+\n+ print(\"Warning: The results of this script may include false positives which are required for different systems\",\n+ file=sys.stderr)\n+\n+ keep_str_fns = uses_libbsd(build_dir) # check for libbsd\n+ if keep_str_fns:\n+ print(\"Warning: libbsd is present, build will fail to detect incorrect removal of rte_string_fns.h\",\n+ file=sys.stderr)\n+ # turn on werror\n+ run_meson(['configure', build_dir, '-Dwerror=true'])\n+ # Use stdin if no iwyu_tool out file given\n+ for line in fileinput.input(args.file):\n+ if 'should remove' in line:\n+ # If the file path in the iwyu_tool output is an absolute path it\n+ # means the file is outside of the dpdk directory, therefore ignore it.\n+ # Also check to see if the file is within the specified sub directory.\n+ filename = line.split()[0]\n+ if (filename != abspath(filename) and\n+ directory in filename):\n+ filepath = relpath(join(build_dir, filename))\n+ elif line.startswith('-') and filepath:\n+ include = '#include ' + line.split()[2]\n+ print(f\"Remove {include} from {filepath} ... \", end='', flush=True)\n+ if keep_str_fns and '<rte_string_fns.h>' in include:\n+ print('skipped')\n+ continue\n+ remove_includes(filepath, include, build_dir)\n+ else:\n+ filepath = None\n+\n+\n+def main():\n+ process(args_parse())\n+\n+\n+if __name__ == '__main__':\n+ main()\n", "prefixes": [ "v7", "01/50" ] }{ "id": 107454, "url": "