diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index 2950b169..e306f3c1 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -38,32 +38,32 @@ def RetrieveCommandLineOptions(self, args): # ####################################################################################### # def GetPackagesSupported(self): - ''' return iterable of edk2 packages supported by this build. - These should be edk2 workspace relative paths ''' + """ return iterable of edk2 packages supported by this build. + These should be edk2 workspace relative paths """ - return ("SurfaceDuo1Pkg","SurfaceDuo2Pkg") + return "SurfaceDuo1Pkg", "SurfaceDuo2Pkg" def GetArchitecturesSupported(self): - ''' return iterable of edk2 architectures supported by this build ''' - return ("AARCH64") + """ return iterable of edk2 architectures supported by this build """ + return "AARCH64" def GetTargetsSupported(self): - ''' return iterable of edk2 target tags supported by this build ''' - return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT") + """ return iterable of edk2 target tags supported by this build """ + return "DEBUG", "RELEASE", "NO-TARGET", "NOOPT" # ####################################################################################### # # Verify and Save requested Ci Build Config # # ####################################################################################### # def SetPackages(self, list_of_requested_packages): - ''' Confirm the requested package list is valid and configure SettingsManager + """ Confirm the requested package list is valid and configure SettingsManager to build the requested packages. Raise UnsupportedException if a requested_package is not supported - ''' + """ unsupported = set(list_of_requested_packages) - \ set(self.GetPackagesSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: logging.critical( "Unsupported Package Requested: " + " ".join(unsupported)) raise Exception("Unsupported Package Requested: " + @@ -71,14 +71,14 @@ def SetPackages(self, list_of_requested_packages): self.ActualPackages = list_of_requested_packages def SetArchitectures(self, list_of_requested_architectures): - ''' Confirm the requests architecture list is valid and configure SettingsManager + """ Confirm the requests architecture list is valid and configure SettingsManager to run only the requested architectures. Raise Exception if a list_of_requested_architectures is not supported - ''' + """ unsupported = set(list_of_requested_architectures) - \ set(self.GetArchitecturesSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: logging.critical( "Unsupported Architecture Requested: " + " ".join(unsupported)) raise Exception( @@ -86,14 +86,14 @@ def SetArchitectures(self, list_of_requested_architectures): self.ActualArchitectures = list_of_requested_architectures def SetTargets(self, list_of_requested_target): - ''' Confirm the request target list is valid and configure SettingsManager + """ Confirm the request target list is valid and configure SettingsManager to run only the requested targets. Raise UnsupportedException if a requested_target is not supported - ''' + """ unsupported = set(list_of_requested_target) - \ set(self.GetTargetsSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: logging.critical( "Unsupported Targets Requested: " + " ".join(unsupported)) raise Exception("Unsupported Targets Requested: " + @@ -105,7 +105,7 @@ def SetTargets(self, list_of_requested_target): # ####################################################################################### # def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ scopes = ("cibuild", "edk2-build", "host-based-test") self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "") @@ -121,9 +121,9 @@ def GetActiveScopes(self): return scopes def GetRequiredSubmodules(self): - ''' return iterable containing RequiredSubmodule objects. + """ return iterable containing RequiredSubmodule objects. If no RequiredSubmodules return an empty iterable - ''' + """ rs = [] # To avoid maintenance of this file for every new submodule @@ -149,7 +149,7 @@ def GetName(self): return "AndromedaPkg" def GetDependencies(self): - ''' Return Git Repository Dependencies + """ Return Git Repository Dependencies Return an iterable of dictionary objects with the following fields { @@ -160,11 +160,11 @@ def GetDependencies(self): Full: Boolean to do shallow or Full checkout. (default is False) ReferencePath: Workspace relative path to git repo to use as "reference" } - ''' + """ return [] def GetPackagesPath(self): - ''' Return a list of workspace relative paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of workspace relative paths that should be mapped as edk2 PackagesPath """ # Include all submodule paths result = ["Platforms"] @@ -174,9 +174,9 @@ def GetPackagesPath(self): return result def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list: - ''' Filter potential packages to test based on changed files. ''' + """ Filter potential packages to test based on changed files. """ return [] diff --git a/Platforms/SurfaceDuo1Pkg/PlatformBuild.py b/Platforms/SurfaceDuo1Pkg/PlatformBuild.py index 15d99fc8..031059b1 100644 --- a/Platforms/SurfaceDuo1Pkg/PlatformBuild.py +++ b/Platforms/SurfaceDuo1Pkg/PlatformBuild.py @@ -4,30 +4,26 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent ## -import datetime import logging import os -import uuid -from io import StringIO -from pathlib import Path from edk2toolext.environment import shell_environment from edk2toolext.environment.uefi_build import UefiBuilder +from edk2toolext.invocables.edk2_parse import ParseSettingsManager from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toolext.invocables.edk2_setup import (RequiredSubmodule, SetupSettingsManager) from edk2toolext.invocables.edk2_update import UpdateSettingsManager -from edk2toolext.invocables.edk2_parse import ParseSettingsManager -from edk2toollib.utility_functions import RunCmd - # ####################################################################################### # - # Common Configuration # - # ####################################################################################### # -class CommonPlatform(): - ''' Common settings for this platform. Define static data here and use + +# ####################################################################################### # +# Common Configuration # +# ####################################################################################### # +class CommonPlatform: + """ Common settings for this platform. Define static data here and use for the different parts of stuart - ''' + """ PackagesSupported = ("SurfaceDuo1Pkg",) ArchSupported = ("AARCH64",) TargetsSupported = ("DEBUG", "RELEASE", "NOOPT") @@ -46,23 +42,24 @@ class CommonPlatform(): "Silicon/QC/Sm8150" ) - # ####################################################################################### # # Configuration for Update & Setup # # ####################################################################################### # + + class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager, ParseSettingsManager): def GetPackagesSupported(self): - ''' return iterable of edk2 packages supported by this build. - These should be edk2 workspace relative paths ''' + """ return iterable of edk2 packages supported by this build. + These should be edk2 workspace relative paths """ return CommonPlatform.PackagesSupported def GetArchitecturesSupported(self): - ''' return iterable of edk2 architectures supported by this build ''' + """ return iterable of edk2 architectures supported by this build """ return CommonPlatform.ArchSupported def GetTargetsSupported(self): - ''' return iterable of edk2 target tags supported by this build ''' + """ return iterable of edk2 target tags supported by this build """ return CommonPlatform.TargetsSupported def GetRequiredSubmodules(self): @@ -85,32 +82,32 @@ def GetRequiredSubmodules(self): ] def SetArchitectures(self, list_of_requested_architectures): - ''' Confirm the requests architecture list is valid and configure SettingsManager + """ Confirm the requests architecture list is valid and configure SettingsManager to run only the requested architectures. Raise Exception if a list_of_requested_architectures is not supported - ''' + """ unsupported = set(list_of_requested_architectures) - \ - set(self.GetArchitecturesSupported()) - if(len(unsupported) > 0): + set(self.GetArchitecturesSupported()) + if len(unsupported) > 0: errorString = ( - "Unsupported Architecture Requested: " + " ".join(unsupported)) - logging.critical( errorString ) - raise Exception( errorString ) + "Unsupported Architecture Requested: " + " ".join(unsupported)) + logging.critical(errorString) + raise Exception(errorString) self.ActualArchitectures = list_of_requested_architectures def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list: - ''' Filter other cases that this package should be built + """ Filter other cases that this package should be built based on changed files. This should cover things that can't - be detected as dependencies. ''' + be detected as dependencies. """ build_these_packages = [] possible_packages = potentialPackagesList.copy() for f in changedFilesList: @@ -128,48 +125,51 @@ def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: li return build_these_packages def GetPlatformDscAndConfig(self) -> tuple: - ''' If a platform desires to provide its DSC then Policy 4 will evaluate if + """ If a platform desires to provide its DSC then Policy 4 will evaluate if any of the changes will be built in the dsc. The tuple should be (, ) - ''' - return ("SurfaceDuo1Pkg/SurfaceDuo1.dsc", {}) + """ + return "SurfaceDuo1Pkg/SurfaceDuo1.dsc", {} def GetName(self): return "SurfaceDuo1" def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ return CommonPlatform.PackagesPath # ####################################################################################### # # Actual Configuration for Platform Build # # ####################################################################################### # + + class PlatformBuilder(UefiBuilder, BuildSettingsManager): def __init__(self): UefiBuilder.__init__(self) def AddCommandLineOptions(self, parserObj): - ''' Add command line options to the argparser ''' + """ Add command line options to the argparser """ # In an effort to support common server based builds this parameter is added. It is # checked for correctness but is never uses as this platform only supports a single set of # architectures. parserObj.add_argument('-a', "--arch", dest="build_arch", type=str, default="AARCH64", - help="Optional - CSV of architecture to build. AARCH64 is used for PEI and " - "DXE and is the only valid option for this platform.") + help="Optional - CSV of architecture to build. AARCH64 is used for PEI and " + "DXE and is the only valid option for this platform.") def RetrieveCommandLineOptions(self, args): - ''' Retrieve command line options from the argparser ''' + """ Retrieve command line options from the argparser """ if args.build_arch.upper() != "AARCH64": - raise Exception("Invalid Arch Specified. Please see comments in PlatformBuild.py::PlatformBuilder::AddCommandLineOptions") + raise Exception( + "Invalid Arch Specified. Please see comments in PlatformBuild.py::PlatformBuilder::AddCommandLineOptions") def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ result = [ shell_environment.GetBuildVars().GetValue("FEATURE_CONFIG_PATH", "") ] @@ -178,11 +178,11 @@ def GetPackagesPath(self): return result def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def GetName(self): - ''' Get the name of the repo, platform, or product being build ''' + """ Get the name of the repo, platform, or product being build """ ''' Used for naming the log file, among others ''' return "SurfaceDuo1Pkg" @@ -218,12 +218,17 @@ def SetPlatformEnv(self): self.env.SetValue("BLD_*_BUILDID_STRING", "Unknown", "Default") # Default turn on build reporting. self.env.SetValue("BUILDREPORTING", "TRUE", "Enabling build report") - self.env.SetValue("BUILDREPORT_TYPES", "PCD DEPEX FLASH BUILD_FLAGS LIBRARY FIXED_ADDRESS HASH", "Setting build report types") + self.env.SetValue("BUILDREPORT_TYPES", "PCD DEPEX FLASH BUILD_FLAGS LIBRARY FIXED_ADDRESS HASH", + "Setting build report types") self.env.SetValue("BLD_*_MEMORY_PROTECTION", "TRUE", "Default") # Include the MFCI test cert by default, override on the commandline with "BLD_*_SHIP_MODE=TRUE" if you want the retail MFCI cert self.env.SetValue("BLD_*_SHIP_MODE", "FALSE", "Default") - self.env.SetValue("CONF_AUTOGEN_INCLUDE_PATH", self.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath("Platforms", "AndromedaPkg", "Include"), "Platform Defined") - self.env.SetValue("MU_SCHEMA_DIR", self.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath("Platforms", "AndromedaPkg", "CfgData"), "Platform Defined") + self.env.SetValue("CONF_AUTOGEN_INCLUDE_PATH", + self.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath("Platforms", "AndromedaPkg", + "Include"), "Platform Defined") + self.env.SetValue("MU_SCHEMA_DIR", + self.edk2path.GetAbsolutePathOnThisSystemFromEdk2RelativePath("Platforms", "AndromedaPkg", + "CfgData"), "Platform Defined") self.env.SetValue("MU_SCHEMA_FILE_NAME", "AndromedaPkgCfgData.xml", "Platform Hardcoded") return 0 @@ -237,6 +242,7 @@ def PlatformPostBuild(self): def FlashRomImage(self): return 0 + if __name__ == "__main__": import argparse import sys @@ -244,11 +250,12 @@ def FlashRomImage(self): from edk2toolext.invocables.edk2_platform_build import Edk2PlatformBuild from edk2toolext.invocables.edk2_setup import Edk2PlatformSetup from edk2toolext.invocables.edk2_update import Edk2Update + print("Invoking Stuart") print(" ) _ _") print(" ( (^)-~-(^)") - print("__,-.\_( 0 0 )__,-.___") - print(" 'W' \ / 'W'") + print(r"__,-.\_( 0 0 )__,-.___") + print(r" 'W' \ / 'W'") print(" >o<") SCRIPT_PATH = os.path.relpath(__file__) parser = argparse.ArgumentParser(add_help=False) @@ -262,11 +269,11 @@ def FlashRomImage(self): new_args = new_args + remaining sys.argv = new_args if args.setup: - print("Running stuart_setup -c " + SCRIPT_PATH) + print(f"Running stuart_setup -c {SCRIPT_PATH}") Edk2PlatformSetup().Invoke() elif args.update: - print("Running stuart_update -c " + SCRIPT_PATH) + print(f"Running stuart_update -c {SCRIPT_PATH}") Edk2Update().Invoke() else: - print("Running stuart_build -c " + SCRIPT_PATH) - Edk2PlatformBuild().Invoke() \ No newline at end of file + print(f"Running stuart_build -c {SCRIPT_PATH}") + Edk2PlatformBuild().Invoke() diff --git a/Platforms/SurfaceDuo1Pkg/PlatformBuildNoSb.py b/Platforms/SurfaceDuo1Pkg/PlatformBuildNoSb.py index 49cdb9d5..cc9372ed 100644 --- a/Platforms/SurfaceDuo1Pkg/PlatformBuildNoSb.py +++ b/Platforms/SurfaceDuo1Pkg/PlatformBuildNoSb.py @@ -4,30 +4,26 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent ## -import datetime import logging import os -import uuid -from io import StringIO -from pathlib import Path from edk2toolext.environment import shell_environment from edk2toolext.environment.uefi_build import UefiBuilder +from edk2toolext.invocables.edk2_parse import ParseSettingsManager from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toolext.invocables.edk2_setup import (RequiredSubmodule, SetupSettingsManager) from edk2toolext.invocables.edk2_update import UpdateSettingsManager -from edk2toolext.invocables.edk2_parse import ParseSettingsManager -from edk2toollib.utility_functions import RunCmd - # ####################################################################################### # + +# ####################################################################################### # # Common Configuration # # ####################################################################################### # -class CommonPlatform(): - ''' Common settings for this platform. Define static data here and use +class CommonPlatform: + """ Common settings for this platform. Define static data here and use for the different parts of stuart - ''' + """ PackagesSupported = ("SurfaceDuo1Pkg",) ArchSupported = ("AARCH64",) TargetsSupported = ("DEBUG", "RELEASE", "NOOPT") @@ -53,16 +49,16 @@ class CommonPlatform(): class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager, ParseSettingsManager): def GetPackagesSupported(self): - ''' return iterable of edk2 packages supported by this build. - These should be edk2 workspace relative paths ''' + """ return iterable of edk2 packages supported by this build. + These should be edk2 workspace relative paths """ return CommonPlatform.PackagesSupported def GetArchitecturesSupported(self): - ''' return iterable of edk2 architectures supported by this build ''' + """ return iterable of edk2 architectures supported by this build """ return CommonPlatform.ArchSupported def GetTargetsSupported(self): - ''' return iterable of edk2 target tags supported by this build ''' + """ return iterable of edk2 target tags supported by this build """ return CommonPlatform.TargetsSupported def GetRequiredSubmodules(self): @@ -85,14 +81,14 @@ def GetRequiredSubmodules(self): ] def SetArchitectures(self, list_of_requested_architectures): - ''' Confirm the requests architecture list is valid and configure SettingsManager + """ Confirm the requests architecture list is valid and configure SettingsManager to run only the requested architectures. Raise Exception if a list_of_requested_architectures is not supported - ''' + """ unsupported = set(list_of_requested_architectures) - \ set(self.GetArchitecturesSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: errorString = ( "Unsupported Architecture Requested: " + " ".join(unsupported)) logging.critical( errorString ) @@ -100,17 +96,17 @@ def SetArchitectures(self, list_of_requested_architectures): self.ActualArchitectures = list_of_requested_architectures def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list: - ''' Filter other cases that this package should be built + """ Filter other cases that this package should be built based on changed files. This should cover things that can't - be detected as dependencies. ''' + be detected as dependencies. """ build_these_packages = [] possible_packages = potentialPackagesList.copy() for f in changedFilesList: @@ -128,18 +124,18 @@ def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: li return build_these_packages def GetPlatformDscAndConfig(self) -> tuple: - ''' If a platform desires to provide its DSC then Policy 4 will evaluate if + """ If a platform desires to provide its DSC then Policy 4 will evaluate if any of the changes will be built in the dsc. The tuple should be (, ) - ''' - return ("SurfaceDuo1Pkg/SurfaceDuo1NoSb.dsc", {}) + """ + return "SurfaceDuo1Pkg/SurfaceDuo1NoSb.dsc", {} def GetName(self): return "SurfaceDuo1" def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ return CommonPlatform.PackagesPath # ####################################################################################### # @@ -150,7 +146,7 @@ def __init__(self): UefiBuilder.__init__(self) def AddCommandLineOptions(self, parserObj): - ''' Add command line options to the argparser ''' + """ Add command line options to the argparser """ # In an effort to support common server based builds this parameter is added. It is # checked for correctness but is never uses as this platform only supports a single set of @@ -160,16 +156,16 @@ def AddCommandLineOptions(self, parserObj): "DXE and is the only valid option for this platform.") def RetrieveCommandLineOptions(self, args): - ''' Retrieve command line options from the argparser ''' + """ Retrieve command line options from the argparser """ if args.build_arch.upper() != "AARCH64": raise Exception("Invalid Arch Specified. Please see comments in PlatformBuild.py::PlatformBuilder::AddCommandLineOptions") def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ result = [ shell_environment.GetBuildVars().GetValue("FEATURE_CONFIG_PATH", "") ] @@ -178,11 +174,11 @@ def GetPackagesPath(self): return result def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def GetName(self): - ''' Get the name of the repo, platform, or product being build ''' + """ Get the name of the repo, platform, or product being build """ ''' Used for naming the log file, among others ''' return "SurfaceDuo1Pkg" @@ -247,8 +243,8 @@ def FlashRomImage(self): print("Invoking Stuart") print(" ) _ _") print(" ( (^)-~-(^)") - print("__,-.\_( 0 0 )__,-.___") - print(" 'W' \ / 'W'") + print(r"__,-.\_( 0 0 )__,-.___") + print(r" 'W' \ / 'W'") print(" >o<") SCRIPT_PATH = os.path.relpath(__file__) parser = argparse.ArgumentParser(add_help=False) diff --git a/Platforms/SurfaceDuo2Pkg/PlatformBuild.py b/Platforms/SurfaceDuo2Pkg/PlatformBuild.py index 4b6631df..bbde9d6c 100644 --- a/Platforms/SurfaceDuo2Pkg/PlatformBuild.py +++ b/Platforms/SurfaceDuo2Pkg/PlatformBuild.py @@ -4,30 +4,26 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent ## -import datetime import logging import os -import uuid -from io import StringIO -from pathlib import Path from edk2toolext.environment import shell_environment from edk2toolext.environment.uefi_build import UefiBuilder +from edk2toolext.invocables.edk2_parse import ParseSettingsManager from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toolext.invocables.edk2_setup import (RequiredSubmodule, SetupSettingsManager) from edk2toolext.invocables.edk2_update import UpdateSettingsManager -from edk2toolext.invocables.edk2_parse import ParseSettingsManager -from edk2toollib.utility_functions import RunCmd - # ####################################################################################### # + +# ####################################################################################### # # Common Configuration # # ####################################################################################### # -class CommonPlatform(): - ''' Common settings for this platform. Define static data here and use +class CommonPlatform: + """ Common settings for this platform. Define static data here and use for the different parts of stuart - ''' + """ PackagesSupported = ("SurfaceDuo2Pkg",) ArchSupported = ("AARCH64",) TargetsSupported = ("DEBUG", "RELEASE", "NOOPT") @@ -53,16 +49,16 @@ class CommonPlatform(): class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager, ParseSettingsManager): def GetPackagesSupported(self): - ''' return iterable of edk2 packages supported by this build. - These should be edk2 workspace relative paths ''' + """ return iterable of edk2 packages supported by this build. + These should be edk2 workspace relative paths """ return CommonPlatform.PackagesSupported def GetArchitecturesSupported(self): - ''' return iterable of edk2 architectures supported by this build ''' + """ return iterable of edk2 architectures supported by this build """ return CommonPlatform.ArchSupported def GetTargetsSupported(self): - ''' return iterable of edk2 target tags supported by this build ''' + """ return iterable of edk2 target tags supported by this build """ return CommonPlatform.TargetsSupported def GetRequiredSubmodules(self): @@ -85,14 +81,14 @@ def GetRequiredSubmodules(self): ] def SetArchitectures(self, list_of_requested_architectures): - ''' Confirm the requests architecture list is valid and configure SettingsManager + """ Confirm the requests architecture list is valid and configure SettingsManager to run only the requested architectures. Raise Exception if a list_of_requested_architectures is not supported - ''' + """ unsupported = set(list_of_requested_architectures) - \ set(self.GetArchitecturesSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: errorString = ( "Unsupported Architecture Requested: " + " ".join(unsupported)) logging.critical( errorString ) @@ -100,17 +96,17 @@ def SetArchitectures(self, list_of_requested_architectures): self.ActualArchitectures = list_of_requested_architectures def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list: - ''' Filter other cases that this package should be built + """ Filter other cases that this package should be built based on changed files. This should cover things that can't - be detected as dependencies. ''' + be detected as dependencies. """ build_these_packages = [] possible_packages = potentialPackagesList.copy() for f in changedFilesList: @@ -128,18 +124,18 @@ def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: li return build_these_packages def GetPlatformDscAndConfig(self) -> tuple: - ''' If a platform desires to provide its DSC then Policy 4 will evaluate if + """ If a platform desires to provide its DSC then Policy 4 will evaluate if any of the changes will be built in the dsc. The tuple should be (, ) - ''' - return ("SurfaceDuo2Pkg/SurfaceDuo2.dsc", {}) + """ + return "SurfaceDuo2Pkg/SurfaceDuo2.dsc", {} def GetName(self): return "SurfaceDuo2" def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ return CommonPlatform.PackagesPath # ####################################################################################### # @@ -150,7 +146,7 @@ def __init__(self): UefiBuilder.__init__(self) def AddCommandLineOptions(self, parserObj): - ''' Add command line options to the argparser ''' + """ Add command line options to the argparser """ # In an effort to support common server based builds this parameter is added. It is # checked for correctness but is never uses as this platform only supports a single set of @@ -160,16 +156,16 @@ def AddCommandLineOptions(self, parserObj): "DXE and is the only valid option for this platform.") def RetrieveCommandLineOptions(self, args): - ''' Retrieve command line options from the argparser ''' + """ Retrieve command line options from the argparser """ if args.build_arch.upper() != "AARCH64": raise Exception("Invalid Arch Specified. Please see comments in PlatformBuild.py::PlatformBuilder::AddCommandLineOptions") def GetWorkspaceRoot(self): - ''' get WorkspacePath ''' + """ get WorkspacePath """ return CommonPlatform.WorkspaceRoot def GetPackagesPath(self): - ''' Return a list of paths that should be mapped as edk2 PackagesPath ''' + """ Return a list of paths that should be mapped as edk2 PackagesPath """ result = [ shell_environment.GetBuildVars().GetValue("FEATURE_CONFIG_PATH", "") ] @@ -178,11 +174,11 @@ def GetPackagesPath(self): return result def GetActiveScopes(self): - ''' return tuple containing scopes that should be active for this process ''' + """ return tuple containing scopes that should be active for this process """ return CommonPlatform.Scopes def GetName(self): - ''' Get the name of the repo, platform, or product being build ''' + """ Get the name of the repo, platform, or product being build """ ''' Used for naming the log file, among others ''' return "SurfaceDuo2Pkg" @@ -247,8 +243,8 @@ def FlashRomImage(self): print("Invoking Stuart") print(" ) _ _") print(" ( (^)-~-(^)") - print("__,-.\_( 0 0 )__,-.___") - print(" 'W' \ / 'W'") + print(r"__,-.\_( 0 0 )__,-.___") + print(r" 'W' \ / 'W'") print(" >o<") SCRIPT_PATH = os.path.relpath(__file__) parser = argparse.ArgumentParser(add_help=False) @@ -262,11 +258,11 @@ def FlashRomImage(self): new_args = new_args + remaining sys.argv = new_args if args.setup: - print("Running stuart_setup -c " + SCRIPT_PATH) + print(f"Running stuart_setup -c {SCRIPT_PATH}") Edk2PlatformSetup().Invoke() elif args.update: - print("Running stuart_update -c " + SCRIPT_PATH) + print(f"Running stuart_update -c {SCRIPT_PATH}") Edk2Update().Invoke() else: - print("Running stuart_build -c " + SCRIPT_PATH) + print(f"Running stuart_build -c {SCRIPT_PATH}") Edk2PlatformBuild().Invoke() \ No newline at end of file diff --git a/Platforms/SurfaceDuo2Pkg/PlatformBuildNoSb.py b/Platforms/SurfaceDuo2Pkg/PlatformBuildNoSb.py index 9c271a32..ed5ae592 100644 --- a/Platforms/SurfaceDuo2Pkg/PlatformBuildNoSb.py +++ b/Platforms/SurfaceDuo2Pkg/PlatformBuildNoSb.py @@ -4,27 +4,23 @@ # Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent ## -import datetime import logging import os -import uuid -from io import StringIO -from pathlib import Path from edk2toolext.environment import shell_environment from edk2toolext.environment.uefi_build import UefiBuilder +from edk2toolext.invocables.edk2_parse import ParseSettingsManager from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toolext.invocables.edk2_setup import (RequiredSubmodule, SetupSettingsManager) from edk2toolext.invocables.edk2_update import UpdateSettingsManager -from edk2toolext.invocables.edk2_parse import ParseSettingsManager -from edk2toollib.utility_functions import RunCmd - # ####################################################################################### # + +# ####################################################################################### # # Common Configuration # # ####################################################################################### # -class CommonPlatform(): +class CommonPlatform: ''' Common settings for this platform. Define static data here and use for the different parts of stuart ''' @@ -92,7 +88,7 @@ def SetArchitectures(self, list_of_requested_architectures): ''' unsupported = set(list_of_requested_architectures) - \ set(self.GetArchitecturesSupported()) - if(len(unsupported) > 0): + if len(unsupported) > 0: errorString = ( "Unsupported Architecture Requested: " + " ".join(unsupported)) logging.critical( errorString ) @@ -133,7 +129,7 @@ def GetPlatformDscAndConfig(self) -> tuple: The tuple should be (, ) ''' - return ("SurfaceDuo2Pkg/SurfaceDuo2NoSb.dsc", {}) + return "SurfaceDuo2Pkg/SurfaceDuo2NoSb.dsc", {} def GetName(self): return "SurfaceDuo2" @@ -247,8 +243,8 @@ def FlashRomImage(self): print("Invoking Stuart") print(" ) _ _") print(" ( (^)-~-(^)") - print("__,-.\_( 0 0 )__,-.___") - print(" 'W' \ / 'W'") + print(r"__,-.\_( 0 0 )__,-.___") + print(r" 'W' \ / 'W'") print(" >o<") SCRIPT_PATH = os.path.relpath(__file__) parser = argparse.ArgumentParser(add_help=False)