Reviewed-by: Michael Kubacki <michael.kuba...@microsoft.com>

On 1/24/2023 11:34 AM, Ard Biesheuvel wrote:
In order to reduce the amount of code duplication, refactor the
PlatformBuild.py script that builds ArmVirtQemu.dsc into a reusable
PlatformBuildLib.py containing most of the bits and pieces, and a small
QemuBuild.py which is specific to the DSC in question.

Suggested-by: Gerd Hoffmann <kra...@redhat.com>
Signed-off-by: Ard Biesheuvel <a...@kernel.org>
---
  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml           | 12 ++++----
  ArmVirtPkg/PlatformCI/{PlatformBuild.py => PlatformBuildLib.py} | 19 
++----------
  ArmVirtPkg/PlatformCI/QemuBuild.py                              | 31 
++++++++++++++++++++
  3 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml 
b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index 5fa7518d2c5e..b1526ae8e50b 100644
--- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -30,42 +30,42 @@ jobs:
      strategy:

          matrix:

            QEMU_AARCH64_DEBUG:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "AARCH64"

              Build.Flags: ""

              Build.Target: "DEBUG"

              Run.Flags: $(run_flags)

              Run: $(should_run)

            QEMU_AARCH64_RELEASE:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "AARCH64"

              Build.Flags: ""

              Build.Target: "RELEASE"

              Run.Flags: $(run_flags)

              Run: $(should_run)

            QEMU_AARCH64_NOOPT:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "AARCH64"

              Build.Flags: ""

              Build.Target: "NOOPT"

              Run.Flags: $(run_flags)

              Run: $(should_run)

            QEMU_ARM_DEBUG:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "ARM"

              Build.Flags: ""

              Build.Target: "DEBUG"

              Run.Flags: $(run_flags)

              Run: $(should_run)

            QEMU_ARM_RELEASE:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "ARM"

              Build.Flags: ""

              Build.Target: "RELEASE"

              Run.Flags: $(run_flags)

              Run: $(should_run)

            QEMU_ARM_NOOPT:

-            Build.File: "$(package)/PlatformCI/PlatformBuild.py"

+            Build.File: "$(package)/PlatformCI/QemuBuild.py"

              Build.Arch: "ARM"

              Build.Flags: ""

              Build.Target: "NOOPT"

diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py 
b/ArmVirtPkg/PlatformCI/PlatformBuildLib.py
similarity index 90%
rename from ArmVirtPkg/PlatformCI/PlatformBuild.py
rename to ArmVirtPkg/PlatformCI/PlatformBuildLib.py
index dff653e919eb..91aa9b31d3c5 100644
--- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
+++ b/ArmVirtPkg/PlatformCI/PlatformBuildLib.py
@@ -17,21 +17,6 @@ from edk2toolext.invocables.edk2_pr_eval import 
PrEvalSettingsManager
  from edk2toollib.utility_functions import RunCmd

  from edk2toollib.utility_functions import GetHostInfo

-# 
#######################################################################################
 #

-#                                Common Configuration                          
           #

-# 
#######################################################################################
 #

-

-

-class CommonPlatform():

-    ''' Common settings for this platform.  Define static data here and use

-        for the different parts of stuart

-    '''

-    PackagesSupported = ("ArmVirtPkg",)

-    ArchSupported = ("AARCH64", "ARM")

-    TargetsSupported = ("DEBUG", "RELEASE", "NOOPT")

-    Scopes = ('armvirt', 'edk2-build')

-    WorkspaceRoot = os.path.realpath(os.path.join(

-        os.path.dirname(os.path.abspath(__file__)), "..", ".."))

      # 
#######################################################################################
 #

      #                         Configuration for Update & Setup                
                #

@@ -139,7 +124,7 @@ class SettingsManager(UpdateSettingsManager, 
SetupSettingsManager, PrEvalSetting
          The tuple should be (<workspace relative path to dsc file>, <input 
dictionary of dsc key value pairs>)

          '''

-        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})

+        return (CommonPlatform.DscName, {})

      # 
#######################################################################################
 #

@@ -163,7 +148,7 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
              "TARGET_ARCH", args.build_arch.upper(), "From CmdLine")

          shell_environment.GetBuildVars().SetValue(

-            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc", "From CmdLine")

+            "ACTIVE_PLATFORM", CommonPlatform.DscName, "From CmdLine")

      def GetWorkspaceRoot(self):

          ''' get WorkspacePath '''

diff --git a/ArmVirtPkg/PlatformCI/QemuBuild.py 
b/ArmVirtPkg/PlatformCI/QemuBuild.py
new file mode 100644
index 000000000000..f4dcc1d1d245
--- /dev/null
+++ b/ArmVirtPkg/PlatformCI/QemuBuild.py
@@ -0,0 +1,31 @@
+# @file

+# Script to Build OVMF UEFI firmware

+#

+# Copyright (c) Microsoft Corporation.

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+import os

+import sys

+

+sys.path.append(os.path.dirname(os.path.abspath(__file__)))

+from PlatformBuildLib import SettingsManager

+from PlatformBuildLib import PlatformBuilder

+

+    # 
#######################################################################################
 #

+    #                                Common Configuration                      
               #

+    # 
#######################################################################################
 #

+class CommonPlatform():

+    ''' Common settings for this platform.  Define static data here and use

+        for the different parts of stuart

+    '''

+    PackagesSupported = ("ArmVirtPkg",)

+    ArchSupported = ("AARCH64", "ARM")

+    TargetsSupported = ("DEBUG", "RELEASE", "NOOPT")

+    Scopes = ('armvirt', 'edk2-build')

+    WorkspaceRoot = os.path.realpath(os.path.join(

+        os.path.dirname(os.path.abspath(__file__)), "..", ".."))

+

+    DscName = os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc")

+

+import PlatformBuildLib

+PlatformBuildLib.CommonPlatform = CommonPlatform



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99077): https://edk2.groups.io/g/devel/message/99077
Mute This Topic: https://groups.io/mt/96501370/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to