]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformCI/PlatformBuild.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / PlatformCI / PlatformBuild.py
index 627bb7b992db095dc6429c6b7184e78e956f1a05..6c541cdea4a5aee515b21e82d2d3d13126855164 100644 (file)
@@ -5,17 +5,11 @@
 # SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ##\r
 import os\r
-import logging\r
-import io\r
-\r
-from edk2toolext.environment import shell_environment\r
-from edk2toolext.environment.uefi_build import UefiBuilder\r
-from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager\r
-from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubmodule\r
-from edk2toolext.invocables.edk2_update import UpdateSettingsManager\r
-from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager\r
-from edk2toollib.utility_functions import RunCmd\r
+import sys\r
 \r
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))\r
+from PlatformBuildLib import SettingsManager\r
+from PlatformBuildLib import PlatformBuilder\r
 \r
     # ####################################################################################### #\r
     #                                Common Configuration                                     #\r
@@ -45,210 +39,5 @@ class CommonPlatform():
         dsc += ".dsc"\r
         return dsc\r
 \r
-\r
-    # ####################################################################################### #\r
-    #                         Configuration for Update & Setup                                #\r
-    # ####################################################################################### #\r
-class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):\r
-\r
-    def GetPackagesSupported(self):\r
-        ''' return iterable of edk2 packages supported by this build.\r
-        These should be edk2 workspace relative paths '''\r
-        return CommonPlatform.PackagesSupported\r
-\r
-    def GetArchitecturesSupported(self):\r
-        ''' return iterable of edk2 architectures supported by this build '''\r
-        return CommonPlatform.ArchSupported\r
-\r
-    def GetTargetsSupported(self):\r
-        ''' return iterable of edk2 target tags supported by this build '''\r
-        return CommonPlatform.TargetsSupported\r
-\r
-    def GetRequiredSubmodules(self):\r
-        ''' return iterable containing RequiredSubmodule objects.\r
-        If no RequiredSubmodules return an empty iterable\r
-        '''\r
-        rs = []\r
-\r
-        # intentionally declare this one with recursive false to avoid overhead\r
-        rs.append(RequiredSubmodule(\r
-            "CryptoPkg/Library/OpensslLib/openssl", False))\r
-\r
-        # To avoid maintenance of this file for every new submodule\r
-        # lets just parse the .gitmodules and add each if not already in list.\r
-        # The GetRequiredSubmodules is designed to allow a build to optimize\r
-        # the desired submodules but it isn't necessary for this repository.\r
-        result = io.StringIO()\r
-        ret = RunCmd("git", "config --file .gitmodules --get-regexp path", workingdir=self.GetWorkspaceRoot(), outstream=result)\r
-        # Cmd output is expected to look like:\r
-        # submodule.CryptoPkg/Library/OpensslLib/openssl.path CryptoPkg/Library/OpensslLib/openssl\r
-        # submodule.SoftFloat.path ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3\r
-        if ret == 0:\r
-            for line in result.getvalue().splitlines():\r
-                _, _, path = line.partition(" ")\r
-                if path is not None:\r
-                    if path not in [x.path for x in rs]:\r
-                        rs.append(RequiredSubmodule(path, True)) # add it with recursive since we don't know\r
-        return rs\r
-\r
-    def SetArchitectures(self, list_of_requested_architectures):\r
-        ''' Confirm the requests architecture list is valid and configure SettingsManager\r
-        to run only the requested architectures.\r
-\r
-        Raise Exception if a list_of_requested_architectures is not supported\r
-        '''\r
-        unsupported = set(list_of_requested_architectures) - set(self.GetArchitecturesSupported())\r
-        if(len(unsupported) > 0):\r
-            errorString = ( "Unsupported Architecture Requested: " + " ".join(unsupported))\r
-            logging.critical( errorString )\r
-            raise Exception( errorString )\r
-        self.ActualArchitectures = list_of_requested_architectures\r
-\r
-    def GetWorkspaceRoot(self):\r
-        ''' get WorkspacePath '''\r
-        return CommonPlatform.WorkspaceRoot\r
-\r
-    def GetActiveScopes(self):\r
-        ''' return tuple containing scopes that should be active for this process '''\r
-        return CommonPlatform.Scopes\r
-\r
-    def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:\r
-        ''' Filter other cases that this package should be built\r
-        based on changed files. This should cover things that can't\r
-        be detected as dependencies. '''\r
-        build_these_packages = []\r
-        possible_packages = potentialPackagesList.copy()\r
-        for f in changedFilesList:\r
-            # BaseTools files that might change the build\r
-            if "BaseTools" in f:\r
-                if os.path.splitext(f) not in [".txt", ".md"]:\r
-                    build_these_packages = possible_packages\r
-                    break\r
-\r
-            # if the azure pipeline platform template file changed\r
-            if "platform-build-run-steps.yml" in f:\r
-                build_these_packages = possible_packages\r
-                break\r
-\r
-        return build_these_packages\r
-\r
-    def GetPlatformDscAndConfig(self) -> tuple:\r
-        ''' If a platform desires to provide its DSC then Policy 4 will evaluate if\r
-        any of the changes will be built in the dsc.\r
-\r
-        The tuple should be (<workspace relative path to dsc file>, <input dictionary of dsc key value pairs>)\r
-        '''\r
-        dsc = CommonPlatform.GetDscName(",".join(self.ActualArchitectures))\r
-        return (f"OvmfPkg/{dsc}", {})\r
-\r
-\r
-    # ####################################################################################### #\r
-    #                         Actual Configuration for Platform Build                         #\r
-    # ####################################################################################### #\r
-class PlatformBuilder( UefiBuilder, BuildSettingsManager):\r
-    def __init__(self):\r
-        UefiBuilder.__init__(self)\r
-\r
-    def AddCommandLineOptions(self, parserObj):\r
-        ''' Add command line options to the argparser '''\r
-        parserObj.add_argument('-a', "--arch", dest="build_arch", type=str, default="IA32,X64",\r
-            help="Optional - CSV of architecture to build.  IA32 will use IA32 for Pei & Dxe. "\r
-            "X64 will use X64 for both PEI and DXE.  IA32,X64 will use IA32 for PEI and "\r
-            "X64 for DXE. default is IA32,X64")\r
-\r
-    def RetrieveCommandLineOptions(self, args):\r
-        '''  Retrieve command line options from the argparser '''\r
-\r
-        shell_environment.GetBuildVars().SetValue("TARGET_ARCH"," ".join(args.build_arch.upper().split(",")), "From CmdLine")\r
-        dsc = CommonPlatform.GetDscName(args.build_arch)\r
-        shell_environment.GetBuildVars().SetValue("ACTIVE_PLATFORM", f"OvmfPkg/{dsc}", "From CmdLine")\r
-\r
-    def GetWorkspaceRoot(self):\r
-        ''' get WorkspacePath '''\r
-        return CommonPlatform.WorkspaceRoot\r
-\r
-    def GetPackagesPath(self):\r
-        ''' Return a list of workspace relative paths that should be mapped as edk2 PackagesPath '''\r
-        return ()\r
-\r
-    def GetActiveScopes(self):\r
-        ''' return tuple containing scopes that should be active for this process '''\r
-        return CommonPlatform.Scopes\r
-\r
-    def GetName(self):\r
-        ''' Get the name of the repo, platform, or product being build '''\r
-        ''' Used for naming the log file, among others '''\r
-        # check the startup nsh flag and if set then rename the log file.\r
-        # this helps in CI so we don't overwrite the build log since running\r
-        # uses the stuart_build command.\r
-        if(shell_environment.GetBuildVars().GetValue("MAKE_STARTUP_NSH", "FALSE") == "TRUE"):\r
-            return "OvmfPkg_With_Run"\r
-        return "OvmfPkg"\r
-\r
-    def GetLoggingLevel(self, loggerType):\r
-        ''' Get the logging level for a given type\r
-        base == lowest logging level supported\r
-        con  == Screen logging\r
-        txt  == plain text file logging\r
-        md   == markdown file logging\r
-        '''\r
-        return logging.DEBUG\r
-\r
-    def SetPlatformEnv(self):\r
-        logging.debug("PlatformBuilder SetPlatformEnv")\r
-        self.env.SetValue("PRODUCT_NAME", "OVMF", "Platform Hardcoded")\r
-        self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to false")\r
-        self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to false")\r
-        return 0\r
-\r
-    def PlatformPreBuild(self):\r
-        return 0\r
-\r
-    def PlatformPostBuild(self):\r
-        return 0\r
-\r
-    def FlashRomImage(self):\r
-        VirtualDrive = os.path.join(self.env.GetValue("BUILD_OUTPUT_BASE"), "VirtualDrive")\r
-        os.makedirs(VirtualDrive, exist_ok=True)\r
-        OutputPath_FV = os.path.join(self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")\r
-\r
-        #\r
-        # QEMU must be on the path\r
-        #\r
-        cmd = "qemu-system-x86_64"\r
-        args  = "-debugcon stdio"                                           # write messages to stdio\r
-        args += " -global isa-debugcon.iobase=0x402"                        # debug messages out thru virtual io port\r
-        args += " -net none"                                                # turn off network\r
-        args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk" # Mount disk with startup.nsh\r
-\r
-        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):\r
-            args += " -display none"  # no graphics\r
-\r
-        if (self.env.GetBuildValue("SMM_REQUIRE") == "1"):\r
-            args += " -machine q35,smm=on" #,accel=(tcg|kvm)"\r
-            #args += " -m ..."\r
-            #args += " -smp ..."\r
-            args += " -global driver=cfi.pflash01,property=secure,value=on"\r
-            args += " -drive if=pflash,format=raw,unit=0,file=" + os.path.join(OutputPath_FV, "OVMF_CODE.fd") + ",readonly=on"\r
-            args += " -drive if=pflash,format=raw,unit=1,file=" + os.path.join(OutputPath_FV, "OVMF_VARS.fd")\r
-        else:\r
-            args += " -pflash " + os.path.join(OutputPath_FV, "OVMF.fd")    # path to firmware\r
-\r
-\r
-        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):\r
-            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")\r
-            f.write("BOOT SUCCESS !!! \n")\r
-            ## add commands here\r
-            f.write("reset -s\n")\r
-            f.close()\r
-\r
-        ret = RunCmd(cmd, args)\r
-\r
-        if ret == 0xc0000005:\r
-            #for some reason getting a c0000005 on successful return\r
-            return 0\r
-\r
-        return ret\r
-\r
-\r
-\r
+import PlatformBuildLib\r
+PlatformBuildLib.CommonPlatform = CommonPlatform\r