Skip to content

Commit

Permalink
BaseTools/Plugin/FlattenPdbs: Add plugin
Browse files Browse the repository at this point in the history
A build plugin that copies all PDB file to a single directory this
can make publishing symbols easier and reduce the size of modules
using ALT PDB path.

Co-authored-by: Bret Barkelew <[email protected]>
Co-authored-by: Joey Vagedes <[email protected]>
Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
3 people committed Jun 21, 2024
1 parent a941de4 commit 1d3072f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
48 changes: 48 additions & 0 deletions BaseTools/Plugin/FlattenPdbs/FlattenPdbs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# @file FlattenPdbs.py
# Plugin to support copying all PDBs to 1 directory.
# This makes symbol publishing easier and with the usage of
# ALT PDB PATH can shrink the size of each module.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
###
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
import logging
from pathlib import Path


class FlattenPdbs(IUefiBuildPlugin):

def do_post_build(self, thebuilder):
# Path to Build output
build_path = Path(thebuilder.env.GetValue("BUILD_OUTPUT_BASE"))
# Path to where the PDBs will be stored
pdb_path = Path(build_path, "PDB")

try:
if not pdb_path.is_dir():
pdb_path.mkdir()
except Exception:
logging.critical("Error making PDB directory")

logging.critical("Copying PDBs to flat directory")
for file in Path(build_path).rglob("*.pdb"):
# PDB exists in DEBUG and OUTPUT directory. Same file.
pdb_out = Path(pdb_path / file.name)
if file.parent.name != "OUTPUT":
continue

# If it exists and has the same file identifier, skip it.
if pdb_out.exists() and file.stat().st_ino == pdb_out.stat().st_ino:
continue

if "vc1" in file.name.lower():
continue

# Hard link it, which is slightly faster, but mainly allows us to tell
# if the file has changed (st_ino is different)
pdb_out.unlink(missing_ok=True)
pdb_out.hardlink_to(file)

return 0
13 changes: 13 additions & 0 deletions BaseTools/Plugin/FlattenPdbs/FlattenPdbs_plug_in.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## @file FlattenPdbs_plug_in.py
#
# Build plugin used to flatten PDB files to a single directory.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

{
"scope": "global",
"name": "Flatten PDBs UEFI Build Plugin",
"module": "FlattenPdbs"
}

0 comments on commit 1d3072f

Please sign in to comment.