Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseTools/Plugin/FlattenPdbs: Add plugin #933

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
Loading