From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C3F45AC1624 for ; Thu, 8 Feb 2024 16:09:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/z6b3zHe7dYscO+BpmPjsHpVReQ9fM+nq5JTtfj6EKQ=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1707408539; v=1; b=OmVfBXwPr6GH2xX9xX7FOYAYHPHLJ7JRVxGOtHcYl4QKH3GZxFelF9EFT73AGviVRm4+e4iR e9L39jgTc2iw/4PcgRvIJeuz97PoZUUnfua8/vH6TpHjFFaCORrNj08G3WAnMPVBVjxcBbPX+TB KYET2usCxhP+695jF966EFxU= X-Received: by 127.0.0.2 with SMTP id NXlUYY7687511xvMMOYPAJi4; Thu, 08 Feb 2024 08:08:59 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.70]) by mx.groups.io with SMTP id smtpd.web10.21452.1707408538607955791 for ; Thu, 08 Feb 2024 08:08:58 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iPyfmv538qh5n4YfmvNGTtTBa65JONn+O7z92CeIfMjnq11AgmlIBNhSTYpgtw7I0iZp8SIr2TtGbfDRh6FwUl7TRXB54OTbbQq1lKwEnrXWfKOOq1OdMc7rwSeHdwbVUAZSuWu0JBBAEUs92stnC+pi7T8s8fyAJv+HZwUMGbMSIWHOQb71G7TxSwkhzi29KtWrJ8ZltEtJQ04xeeDpqqWyW9JzzwInOpuo4zr3PBhpggXhB23aRqtLgGY87wvvhdt4u5CEeEokrGlukGeogDN1izda23fR2Y1KciMRDHDpr9YVtSa2M0lsIcURlESVSbgUgqxabDs3vGQA6Sv/EA== 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=Cj8ps6Af1rQh3hgbNJlUYxSVpbad4g5t06FMll0lfxk=; b=Q0/pKpg8F63UHcErCNca8B4WnCdYIeIHxoavNYR7IXbnK2NU44bTCvM+xT+Z30xCyc1hs6VkF06naSeFub1IjnvX7WvL3B00w8//ppP0F+BgZWRmTsMdVvnSH8aX1pBDYqVTmtYZj2yYWb0Nd8Gjs5ordLSoQhfnTS7gf4FIGXiGxcD0vbXj0/CpNdVxaXOKsAVZMTQiPOWca177jIYkQTJDJLUXp3A83tS5ygmObG9X3zKJiae1HtLl0ot7+WoCgSML6ZbNtBH+qcQl6eLfi29ZgfOO4dn28fr3LxjVPgNwUECoJZUA0tRK+sdaWo9WZmO+WRVO2bwkOu5XtGgaLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from BLAP220CA0014.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:32c::19) by DS7PR12MB5766.namprd12.prod.outlook.com (2603:10b6:8:75::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.17; Thu, 8 Feb 2024 16:08:55 +0000 X-Received: from BL02EPF0001A101.namprd05.prod.outlook.com (2603:10b6:208:32c:cafe::70) by BLAP220CA0014.outlook.office365.com (2603:10b6:208:32c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.38 via Frontend Transport; Thu, 8 Feb 2024 16:08:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0001A101.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Thu, 8 Feb 2024 16:08:54 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 8 Feb 2024 08:08:34 -0800 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 8 Feb 2024 08:08:33 -0800 X-Received: from 80d647148241.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 8 Feb 2024 08:08:33 -0800 From: "Jeff Brasen via groups.io" To: CC: , , , , , "Jeff Brasen" Subject: [edk2-devel] [PATCH] BaseTools/BuildReport: Improve compile_commands generation Date: Thu, 8 Feb 2024 00:11:13 -0800 Message-ID: <80723a8e2492be8fb2834a08506189af1cde3b94.1707379735.git.jbrasen@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A101:EE_|DS7PR12MB5766:EE_ X-MS-Office365-Filtering-Correlation-Id: 7179f99f-8848-4cf7-9195-08dc28c03fb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: W/R63KaDykNcVe0h01Hn3hxDlpUcpjYmoH7hvIi3VC3fP9+HmD20DssvAwKK7aRFJs3ikw1+M1IbwVBDr37yHesVjLHaFVHwLnLpjd4QwaTt+TJbiuitk1BBq5+uY+q4HfHv0+RitpSj5aY+wwepfKpBkpH3oXYxgneugF+fdCVo32GXtirfaoepuJz+Me6g6zBvdxntIUGHfAAWEkG6UsdODu18cuJaAD/HgGLG5muRWViudOErGu+hGU22EbDWRmOES+VyUfLfBf4/nbW043YVSiNG7DccF+3wngmyy3L6ceuMpqvgBM9VqNz5kThdyB7rKSZl9KZxzRsvNFKiGnNQyA6ZBTjfcSVA1a6Bhk4LJCA6tKBrHm1UtpMh6iTj5QfDk3JcDiH/e8Uv5kZudYM/ptJUiFqJQiNdznMTNHW6DChV/LpLtL65pPMmOO/0VFZL37m/I78kDgu61eCoGyxcSl3bdZ7g00CLHBj2ZslPaprFFjrVwxmtc/RkbQbU7EOkQQVTTSZYnq7PugvYr9imgvjL6r9Cc1q0ndSJw84fKBQfPac3NFBLh1w++IvmiU27/Xn0VdnUUB9cUGwtfrOsvS1iV6NgUIqy5Hgb2QM= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2024 16:08:54.5301 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7179f99f-8848-4cf7-9195-08dc28c03fb3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A101.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5766 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jbrasen@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZXb7U7uJAPeDVd62w2d53oHGx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=OmVfBXwP; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io This produces output that matches CodeChecker log command - Set directory to build output path - Set build destination to the object created instead of the path - Add recursive macro support - Add lookup in module.Macros dictionary - Add leading include flag to include list - Add source file to compile commands Signed-off-by: Jeff Brasen --- BaseTools/Source/Python/build/BuildReport.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index 26dfe53fff..497bbbd646 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -2416,20 +2416,27 @@ class BuildReport(object): # Generate compile command for each c file # compile_command["file"] =3D source.Path - compile_command["directory"] =3D source.Di= r + compile_command["directory"] =3D module.Bu= ildDir build_command =3D module.BuildRules[source= .Ext].CommandList[0] + destination =3D os.path.join (module.Outpu= tDir, os.path.join (source.SubDir, source.BaseName + ".obj")) build_command_variables =3D re.findall(r"\= $\((.*?)\)", build_command) - for var in build_command_variables: + while build_command_variables: + var =3D build_command_variables.pop() var_tokens =3D var.split("_") var_main =3D var_tokens[0] - if len(var_tokens) =3D=3D 1: + if var =3D=3D "INC": + var_value =3D inc_flag + f" {inc_f= lag}".join(module.IncludePathList) + elif var in module.Macros: + var_value =3D module.Macros[var] + elif len(var_tokens) =3D=3D 1: var_value =3D module.BuildOption[v= ar_main]["PATH"] else: var_value =3D module.BuildOption[v= ar_main][var_tokens[1]] build_command =3D build_command.replac= e(f"$({var})", var_value) - include_files =3D f" {inc_flag}".join(= module.IncludePathList) - build_command =3D build_command.replac= e("${src}", include_files) - build_command =3D build_command.replac= e("${dst}", module.OutputDir) + build_command =3D build_command.replac= e("${src}", source.Path) + build_command =3D build_command.replac= e("${dst}", destination) + build_command =3D build_command.replac= e("$@", destination) + build_command_variables.extend (re.fin= dall(r"\$\((.*?)\)", var_value)) =20 # Remove un defined macros compile_command["command"] =3D re.sub(r"\$= \(.*?\)", "", build_command) --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115267): https://edk2.groups.io/g/devel/message/115267 Mute This Topic: https://groups.io/mt/104241385/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-