From 01a06884a173a40bde00d2bdbf9d89224a4b00f4 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 24 Jan 2023 15:34:24 +0000 Subject: [PATCH] ArmVirtPkg/PlatformCI: factor out reusable PlatformBuildLib.py 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 Signed-off-by: Ard Biesheuvel Acked-by: Gerd Hoffmann Reviewed-by: Michael Kubacki --- .../.azurepipelines/Ubuntu-GCC5.yml | 12 +++---- .../{PlatformBuild.py => PlatformBuildLib.py} | 19 ++---------- ArmVirtPkg/PlatformCI/QemuBuild.py | 31 +++++++++++++++++++ 3 files changed, 39 insertions(+), 23 deletions(-) rename ArmVirtPkg/PlatformCI/{PlatformBuild.py => PlatformBuildLib.py} (90%) create mode 100644 ArmVirtPkg/PlatformCI/QemuBuild.py diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml index 5fa7518d2c..b1526ae8e5 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 dff653e919..91aa9b31d3 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 (, ) ''' - 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 0000000000..f4dcc1d1d2 --- /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