public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Michael Kubacki <michael.kubacki@microsoft.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Oliver Steffen <osteffen@redhat.com>
Subject: [PATCH v2 3/6] ArmVirtPkg/PlatformCI: factor out reusable PlatformBuildLib.py
Date: Tue, 24 Jan 2023 17:34:14 +0100	[thread overview]
Message-ID: <20230124163417.584727-4-ardb@kernel.org> (raw)
In-Reply-To: <20230124163417.584727-1-ardb@kernel.org>

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 <kraxel@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@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
-- 
2.39.0


  parent reply	other threads:[~2023-01-24 16:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 16:34 [PATCH v2 0/6] ArmVirtPkg: Increase PlatformCI coverage Ard Biesheuvel
2023-01-24 16:34 ` [PATCH v2 1/6] ArmVirtPkg/PrePi: Ensure timely execution of library constructors Ard Biesheuvel
2023-01-24 16:34 ` [PATCH v2 2/6] ArmVirtPkg/ArmVirtQemu: enlarge initial flash mapping Ard Biesheuvel
2023-01-24 16:34 ` Ard Biesheuvel [this message]
2023-01-26 14:34   ` [edk2-devel] [PATCH v2 3/6] ArmVirtPkg/PlatformCI: factor out reusable PlatformBuildLib.py Michael Kubacki
2023-01-24 16:34 ` [PATCH v2 4/6] ArmVirtPkg/PlatformCI: Enable optional features on Qemu AARCH64 builds Ard Biesheuvel
2023-01-26 14:35   ` [edk2-devel] " Michael Kubacki
2023-01-24 16:34 ` [PATCH v2 5/6] ArmVirtPkg/PlatformCI: Add CI coverage for ArmVirtQemuKernel Ard Biesheuvel
2023-01-26 14:35   ` [edk2-devel] " Michael Kubacki
2023-01-24 16:34 ` [PATCH v2 6/6] ArmVirtPkg/PlatformCI: Perform build test of ArmVirtKvmTool Ard Biesheuvel
2023-01-26 14:35   ` [edk2-devel] " Michael Kubacki
2023-01-25  9:41 ` [edk2-devel] [PATCH v2 0/6] ArmVirtPkg: Increase PlatformCI coverage Gerd Hoffmann
2023-01-25 12:38   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230124163417.584727-4-ardb@kernel.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox