Skip to content

Commit

Permalink
Resolve mws deprecations (#539)
Browse files Browse the repository at this point in the history
## Description

thebuilder.mws was deprecated in favor of thebuilder.edk2path. this
commit removes any usage of thebuilder.mws and replaces it with
thebuilder.edk2path. Now that edk2path is available, it also removes the
manual instantiation of an Edk2Path object in favor of the existing
edk2path that is now associated with thebuilder.

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [x] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

verified `stuart_ci_build` success for MU_BASECORE
verified `stuart_build` success for mu_tiano_platforms

## Integration Instructions

Ensure edk2-pytool-extensions is v0.24.0 or greater.
  • Loading branch information
Javagedes authored Aug 28, 2023
1 parent 2491955 commit 46dfa47
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 49 deletions.
20 changes: 10 additions & 10 deletions .pytool/Plugin/CodeQL/CodeQlAnalyzePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ def do_post_build(self, builder: UefiBuilder) -> int:
int: The number of CodeQL errors found. Zero indicates that
AuditOnly mode is enabled or no failures were found.
"""

pp = builder.pp.split(os.pathsep)
edk2_path = Edk2Path(builder.ws, pp)

self.builder = builder
self.package = edk2_path.GetContainingPackage(
builder.mws.join(builder.ws,
builder.env.GetValue(
"ACTIVE_PLATFORM")))
self.package = builder.edk2path.GetContainingPackage(
builder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
builder.env.GetValue("ACTIVE_PLATFORM")
)
)

self.package_path = Path(
edk2_path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
self.package))
builder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
self.package
)
)
self.target = builder.env.GetValue("TARGET")

self.codeql_db_path = codeql_plugin.get_codeql_db_path(
Expand Down
17 changes: 7 additions & 10 deletions .pytool/Plugin/CodeQL/CodeQlBuildPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ def do_pre_build(self, builder: UefiBuilder) -> int:
"""

if not builder.SkipBuild:
pp = builder.pp.split(os.pathsep)
edk2_path = Edk2Path(builder.ws, pp)

self.builder = builder
self.package = edk2_path.GetContainingPackage(
builder.mws.join(builder.ws,
builder.env.GetValue(
"ACTIVE_PLATFORM")))
self.package = builder.edk2path.GetContainingPackage(
builder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
builder.env.GetValue("ACTIVE_PLATFORM")
)
)

self.target = builder.env.GetValue("TARGET")

self.build_output_dir = builder.env.GetValue("BUILD_OUTPUT_BASE")
Expand Down Expand Up @@ -89,9 +88,7 @@ def do_pre_build(self, builder: UefiBuilder) -> int:
# Since it's unclear how quotes are handled and may change in the
# future, this code is going to use the workaround to place the
# command in an executable file that is instead passed to CodeQL.
self.codeql_cmd_path = Path(builder.mws.join(
builder.ws, self.build_output_dir,
"codeql_build_command"))
self.codeql_cmd_path = Path(self.build_output_dir, "codeql_build_command")

build_params = self._get_build_params()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def do_pre_build(self, builder: UefiBuilder) -> int:
if "no-target" in build_target:
return 0

pp = builder.pp.split(os.pathsep)
edk2 = Edk2Path(builder.ws, pp)
edk2 = builder.edk2path
package = edk2.GetContainingPackage(
builder.mws.join(builder.ws,
builder.env.GetValue(
"ACTIVE_PLATFORM")))
builder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
builder.env.GetValue("ACTIVE_PLATFORM")
)
)
package_path = Path(
edk2.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
package))
Expand Down
4 changes: 1 addition & 3 deletions .pytool/Plugin/ImageValidation/ImageValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def do_post_build(self, thebuilder):
fdf_parser = FdfParser()
dsc_parser = DscParser()

ws = thebuilder.ws
pp = thebuilder.pp.split(os.pathsep)
edk2 = Edk2Path(ws, pp)
edk2 = thebuilder.edk2path

ActiveDsc = edk2.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
thebuilder.env.GetValue("ACTIVE_PLATFORM"))
Expand Down
4 changes: 1 addition & 3 deletions BaseTools/Plugin/BmpCheck/BmpCheckPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def do_pre_build(self, thebuilder):
fp = FdfParser()
dp = DscParser()

ws = thebuilder.ws
pp = thebuilder.pp.split(";")
edk2 = Edk2Path(ws, pp)
edk2 = thebuilder.edk2path

ActiveDsc = edk2.GetAbsolutePathOnThisSystemFromEdk2RelativePath(
thebuilder.env.GetValue("ACTIVE_PLATFORM"))
Expand Down
2 changes: 1 addition & 1 deletion BaseTools/Plugin/FdSizeReport/FdSizeReportGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def do_post_build(self, thebuilder):
#1 - Get the output path for report file
OutF = thebuilder.env.GetValue("FDSIZEREPORT_FILE")
#2 - Get the FDF path
FdfF = thebuilder.mws.join(thebuilder.ws, thebuilder.env.GetValue("FLASH_DEFINITION"))
FdfF = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(thebuilder.env.GetValue("FLASH_DEFINITION"))
#3 - Get the product name
Product = thebuilder.env.GetValue("PRODUCT_NAME")
if Product is None:
Expand Down
18 changes: 8 additions & 10 deletions BaseTools/Plugin/OverrideValidation/OverrideValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def override_plat_validate(self, thebuilder):
result = self.OverrideResult.OR_ALL_GOOD
InfFileList = self.get_dsc_inf_list(thebuilder)

ws = thebuilder.ws
pp = thebuilder.pp.split(os.pathsep)
self.PathTool = Edk2Path(ws, pp)
self.PathTool = thebuilder.edk2path

if (InfFileList == []):
return result
Expand All @@ -120,7 +118,7 @@ def override_plat_validate(self, thebuilder):
for file in InfFileList:
temp_list = []
modulenode = self.ModuleNode(file, self.OverrideResult.OR_ALL_GOOD, 0)
fullpath = thebuilder.mws.join(thebuilder.ws, file)
fullpath = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(file)

m_result = self.override_detect_process(thebuilder, fullpath, temp_list, modulenode, status)
# Do not log the module that does not have any override records
Expand Down Expand Up @@ -291,7 +289,7 @@ def override_process_line_with_version1(self, thebuilder, filelist, OverrideEntr
# Step 2: Process the path to overridden module
# Normalize the path to support different slashes, then strip the initial '\\' to make sure os.path.join will work correctly
overriddenpath = os.path.normpath(OverrideEntry[1].strip()).strip('\\')
fullpath = os.path.normpath(thebuilder.mws.join(thebuilder.ws, overriddenpath))
fullpath = os.path.normpath(thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(overriddenpath))
# Search overridden module in workspace
if not os.path.isfile(fullpath) and not os.path.isdir(fullpath):
logging.info("Inf Overridden File/Path Not Found in Workspace or Packages_Path: %s" %(overriddenpath))
Expand Down Expand Up @@ -354,7 +352,7 @@ def override_process_line_with_version2(self, thebuilder, filelist, OverrideEntr
# if we failed, do a diff of the overridden file (as long as exist) and show the output
if result != self.OverrideResult.OR_ALL_GOOD and result != self.OverrideResult.OR_TARGET_INF_NOT_FOUND:
overriddenpath = os.path.normpath(OverrideEntry[1].strip()).strip('\\')
fullpath = os.path.normpath(thebuilder.mws.join(thebuilder.ws, overriddenpath))
fullpath = os.path.normpath(thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(overriddenpath))
if os.path.exists(fullpath):
patch = ModuleGitPatch(fullpath, GitHash)
# TODO: figure out how to get the log file
Expand Down Expand Up @@ -429,7 +427,7 @@ def override_log_print(self, thebuilder, modulelist, status):
# stack: the stack of paths collected during a dfs for loop detection, should be absolute path and lower case all the time
# log: log file object, must be readily open for file write when called
def node_dfs(self, thebuilder, node, stack, log):
fullpath = os.path.normpath(thebuilder.mws.join(thebuilder.ws, node.path)).lower()
fullpath = os.path.normpath(thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(node.path)).lower()
if (node.path in stack):
return
stack.append(fullpath)
Expand Down Expand Up @@ -458,19 +456,19 @@ def get_dsc_inf_list(self, thebuilder):
logging.debug("Parse Active Platform DSC file")
input_vars = thebuilder.env.GetAllBuildKeyValues()
input_vars["TARGET"] = thebuilder.env.GetValue("TARGET")
dscp = DscParser().SetEdk2Path(Edk2Path(thebuilder.ws, thebuilder.pp.split(os.pathsep))).SetInputVars(input_vars)
dscp = DscParser().SetEdk2Path(thebuilder.edk2path).SetInputVars(input_vars)
plat_dsc = thebuilder.env.GetValue("ACTIVE_PLATFORM")
if (plat_dsc is None):
return InfFileList

# Parse the DSC
pa = thebuilder.mws.join(thebuilder.ws, plat_dsc)
pa = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(plat_dsc)
dscp.ParseFile(pa)
# Add the DSC itself (including all the includes)
InfFileList.extend(dscp.GetAllDscPaths())
# Add the FDF
if "FLASH_DEFINITION" in dscp.LocalVars:
fd = thebuilder.mws.join(thebuilder.ws, dscp.LocalVars["FLASH_DEFINITION"])
fd = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(dscp.LocalVars["FLASH_DEFINITION"])
InfFileList.append(fd)
# Here we collect all the reference libraries, IA-32 modules, x64 modules and other modules
if (dscp.Parsed) :
Expand Down
12 changes: 5 additions & 7 deletions PolicyServicePkg/Plugins/UpdatePolicyHdr/UpdatePolicyHdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ def do_pre_build(self, thebuilder):

yaml_list = []
exception_list = []
ws = thebuilder.ws
pp = thebuilder.pp.split(os.pathsep)
edk2 = Edk2Path(ws, pp)
edk2 = thebuilder.edk2path

# Form the exception list of formatted absolute paths. And always ignore our own samples.
exception_list.append (thebuilder.mws.join (thebuilder.ws, "PolicyServicePkg", "Samples"))
exception_list.append (edk2.GetAbsolutePathOnThisSystemFromEdk2RelativePath("PolicyServicePkg", "Samples"))
platform_exception = thebuilder.env.GetValue("POLICY_IGNORE_PATHS")
if platform_exception is not None:
plat_list = platform_exception.split(';')
for each in plat_list:
exception_list.append(os.path.normpath (thebuilder.mws.join (thebuilder.ws, each)))
exception_list.append(os.path.normpath (edk2.GetAbsolutePathOnThisSystemFromEdk2RelativePath(each)))

# Look for *_policy_def.yaml files in all package paths.
for pkg_path in pp:
Expand Down Expand Up @@ -151,11 +149,11 @@ def do_pre_build(self, thebuilder):
os.mkdir (final_dir)

# Set up a playground first
op_dir = thebuilder.mws.join(thebuilder.ws, thebuilder.env.GetValue("BUILD_OUTPUT_BASE"), "ConfPolicy")
op_dir = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath(thebuilder.env.GetValue("BUILD_OUTPUT_BASE"), "ConfPolicy")
if not os.path.isdir(op_dir):
os.makedirs(op_dir)

cmd = thebuilder.mws.join(thebuilder.ws, "PolicyServicePkg", "Tools", "GenCfgData.py")
cmd = thebuilder.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath("PolicyServicePkg", "Tools", "GenCfgData.py")

conf_file = setting
if conf_file is None:
Expand Down

0 comments on commit 46dfa47

Please sign in to comment.