Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/100423/?format=api
http://patches.dpdk.org/api/patches/100423/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20211004101058.2396458-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": "<20211004101058.2396458-2-sean.morrissey@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20211004101058.2396458-2-sean.morrissey@intel.com", "date": "2021-10-04T10:10:54", "name": "[v1,1/5] devtools: script to remove unused headers includes", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "7de88de6ffd31b9c54cfeae3882d0396f5cca166", "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/20211004101058.2396458-2-sean.morrissey@intel.com/mbox/", "series": [ { "id": 19360, "url": "http://patches.dpdk.org/api/series/19360/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=19360", "date": "2021-10-04T10:10:53", "name": "introduce IWYU", "version": 1, "mbox": "http://patches.dpdk.org/series/19360/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/100423/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/100423/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 B1BD0A0C4C;\n\tMon, 4 Oct 2021 12:11:44 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3871341314;\n\tMon, 4 Oct 2021 12:11:40 +0200 (CEST)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by mails.dpdk.org (Postfix) with ESMTP id 84A2841300\n for <dev@dpdk.org>; Mon, 4 Oct 2021 12:11:38 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 04 Oct 2021 03:11:36 -0700", "from silpixa00401215.ir.intel.com ([10.55.128.96])\n by FMSMGA003.fm.intel.com with ESMTP; 04 Oct 2021 03:11:34 -0700" ], "X-IronPort-AV": [ "E=McAfee;i=\"6200,9189,10126\"; a=\"205501908\"", "E=Sophos;i=\"5.85,345,1624345200\"; d=\"scan'208\";a=\"205501908\"", "E=Sophos;i=\"5.85,345,1624345200\"; d=\"scan'208\";a=\"558342028\"" ], "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>", "Date": "Mon, 4 Oct 2021 10:10:54 +0000", "Message-Id": "<20211004101058.2396458-2-sean.morrissey@intel.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211004101058.2396458-1-sean.morrissey@intel.com>", "References": "<20211004101058.2396458-1-sean.morrissey@intel.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v1 1/5] devtools: script to remove unused headers\n includes", "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", "Sender": "\"dev\" <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.\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>\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..ddc4ceafa4\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+def args_parse():\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, help='Name of the build directory in which the IWYU tool was used in.', default=\"build\")\n+ parser.add_argument('-d', '--sub_dir', type=str, help='The sub-directory to remove headers from.', default=\"\")\n+ parser.add_argument('file', type=Path, help='The path to the IWYU log file or output from stdin.')\n+\n+ args = parser.parse_args()\n+\n+ return args\n+\n+\n+def run_meson(args):\n+ \"Runs a meson command logging output to process.log\"\n+ with open('process.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(filename, include, dpdk_dir, build_dir):\n+ # Load in file - readlines()\n+ # loop through list once in mem -> make cpy of list with line removed\n+ # write cpy -> stored in memory so write cpy to file then check\n+ # run test build -> call ninja on the build folder, ninja -C build, subprocess\n+ # if fails -> write original back to file otherwise continue on\n+ # newlist = [ln for ln in lines if not ln.startswith(...)] filters out one element\n+ filepath = filename\n+\n+ with open(filepath, 'r+') 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 ln.strip(\"\\n\") != include:\n+ f.write(ln)\n+\n+ ret = run_meson(['compile', '-C', join(dpdk_dir, 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+ filename = None\n+ build_dir = args.build_dir\n+ dpdk_dir = abspath(__file__).split('/devtools')[0]\n+ directory = args.sub_dir\n+ # Use stdin if no iwyu_tool out file given\n+ logfile = abspath(args.file) if str(args.file) != '-' else args.file\n+\n+ keep_str_fns = uses_libbsd(join(dpdk_dir, 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+ run_meson(['configure', dpdk_dir + \"/\" + build_dir, '-Dwerror=true']) # turn on werror\n+\n+ for line in fileinput.input(logfile):\n+ if 'should remove' in line:\n+ # If the file path in the iwyu_tool output is an absolute path\n+ # it 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+ if line.split()[0] != abspath(line.split()[0]) and directory in line.split()[0]:\n+ filename = relpath(join(build_dir, line.split()[0]))\n+ elif line.startswith('-') and filename:\n+ include = '#include ' + line.split()[2]\n+ print(f\"Remove {include} from {filename} ... \", end='', flush=True)\n+ if keep_str_fns and '<rte_string_fns.h>' in include:\n+ print('skipped')\n+ continue\n+ remove_includes(filename, include, dpdk_dir, build_dir)\n+ else:\n+ filename = None\n+\n+\n+def main():\n+ args = args_parse()\n+ process(args)\n+\n+\n+if __name__ == '__main__':\n+ main()\n", "prefixes": [ "v1", "1/5" ] }{ "id": 100423, "url": "