|
| 1 | +## |
| 2 | +# Copyright (c) Microsoft Corporation. |
| 3 | +# SPDX-License-Identifier: BSD-2-Clause-Patent |
| 4 | +## |
| 5 | + |
| 6 | +import datetime |
| 7 | +import logging |
| 8 | +import os |
| 9 | +import uuid |
| 10 | + |
| 11 | +from io import StringIO |
| 12 | +from pathlib import Path |
| 13 | + |
| 14 | +from edk2toolext.environment import shell_environment |
| 15 | +from edk2toolext.environment.uefi_build import UefiBuilder |
| 16 | +from edk2toolext.invocables.edk2_platform_build import BuildSettingsManager |
| 17 | +from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager |
| 18 | +from edk2toolext.invocables.edk2_setup import (RequiredSubmodule, SetupSettingsManager) |
| 19 | +from edk2toolext.invocables.edk2_update import UpdateSettingsManager |
| 20 | +from edk2toolext.invocables.edk2_parse import ParseSettingsManager |
| 21 | +from edk2toollib.utility_functions import RunCmd |
| 22 | + |
| 23 | +# ####################################################################################### # |
| 24 | +# Common Configuration # |
| 25 | +# ####################################################################################### # |
| 26 | +class CommonPlatform (): |
| 27 | + PackagesSupported = ("onyxPkg") |
| 28 | + ArchSupported = ("AARCH64") |
| 29 | + TargetsSupported = ("DEBUG", "RELEASE") |
| 30 | + Scopes = ('onyx', 'gcc_aarch64_linux', 'edk2-build') |
| 31 | + WorkspaceRoot = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) |
| 32 | + PackagesPath = ( |
| 33 | + "Platforms/Xiaomi", |
| 34 | + "Common/Mu", |
| 35 | + "Common/Mu_OEM_Sample", |
| 36 | + "Mu_Basecore", |
| 37 | + "Silicon/Qualcomm", |
| 38 | + "Silicon/Silicium", |
| 39 | + "Silicium-ACPI", |
| 40 | + "Silicium-ACPI/Platforms/Xiaomi", |
| 41 | + "Silicium-ACPI/SoCs/Qualcomm" |
| 42 | + ) |
| 43 | + |
| 44 | +# ####################################################################################### # |
| 45 | +# Configuration for Update & Setup # |
| 46 | +# ####################################################################################### # |
| 47 | +class SettingsManager (UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager, ParseSettingsManager): |
| 48 | + |
| 49 | + def GetPackagesSupported (self): |
| 50 | + return CommonPlatform.PackagesSupported |
| 51 | + |
| 52 | + def GetArchitecturesSupported (self): |
| 53 | + return CommonPlatform.ArchSupported |
| 54 | + |
| 55 | + def GetTargetsSupported (self): |
| 56 | + return CommonPlatform.TargetsSupported |
| 57 | + |
| 58 | + def GetRequiredSubmodules (self): |
| 59 | + return [ |
| 60 | + RequiredSubmodule ("Binaries", True), |
| 61 | + RequiredSubmodule ("Common/Mu", True), |
| 62 | + RequiredSubmodule ("Common/Mu_OEM_Sample", True), |
| 63 | + RequiredSubmodule ("Mu_Basecore", True), |
| 64 | + RequiredSubmodule ("Silicium-ACPI", True), |
| 65 | + RequiredSubmodule ("Silicon/Silicium/OpensslPkg/Library/OpensslLib/openssl", True) |
| 66 | + ] |
| 67 | + |
| 68 | + def SetArchitectures (self, list_of_requested_architectures): |
| 69 | + unsupported = set(list_of_requested_architectures) - set(self.GetArchitecturesSupported()) |
| 70 | + |
| 71 | + if (len(unsupported) > 0): |
| 72 | + errorString = ("Unsupported Architecture Requested: " + " ".join(unsupported)) |
| 73 | + logging.critical (errorString) |
| 74 | + raise Exception (errorString) |
| 75 | + |
| 76 | + self.ActualArchitectures = list_of_requested_architectures |
| 77 | + |
| 78 | + def GetWorkspaceRoot (self): |
| 79 | + return CommonPlatform.WorkspaceRoot |
| 80 | + |
| 81 | + def GetActiveScopes (self): |
| 82 | + return CommonPlatform.Scopes |
| 83 | + |
| 84 | + def FilterPackagesToTest (self, changedFilesList: list, potentialPackagesList: list) -> list: |
| 85 | + build_these_packages = [] |
| 86 | + possible_packages = potentialPackagesList.copy () |
| 87 | + |
| 88 | + for f in changedFilesList: |
| 89 | + if "BaseTools" in f: |
| 90 | + if os.path.splitext(f) not in [".txt", ".md"]: |
| 91 | + build_these_packages = possible_packages |
| 92 | + break |
| 93 | + |
| 94 | + if "platform-build-run-steps.yml" in f: |
| 95 | + build_these_packages = possible_packages |
| 96 | + break |
| 97 | + |
| 98 | + return build_these_packages |
| 99 | + |
| 100 | + def GetPlatformDscAndConfig (self) -> tuple: |
| 101 | + return ("onyxPkg/onyx.dsc", {}) |
| 102 | + |
| 103 | + def GetName (self): |
| 104 | + return "onyx" |
| 105 | + |
| 106 | + def GetPackagesPath (self): |
| 107 | + return CommonPlatform.PackagesPath |
| 108 | + |
| 109 | +# ####################################################################################### # |
| 110 | +# Actual Configuration for Platform Build # |
| 111 | +# ####################################################################################### # |
| 112 | +class PlatformBuilder (UefiBuilder, BuildSettingsManager): |
| 113 | + def __init__ (self): |
| 114 | + UefiBuilder.__init__ (self) |
| 115 | + |
| 116 | + def AddCommandLineOptions (self, parserObj): |
| 117 | + 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.") |
| 118 | + |
| 119 | + def RetrieveCommandLineOptions (self, args): |
| 120 | + if args.build_arch.upper() != "AARCH64": |
| 121 | + raise Exception("Invalid Arch Specified. Please see comments in DeviceBuild.py::PlatformBuilder::AddCommandLineOptions") |
| 122 | + |
| 123 | + def GetWorkspaceRoot (self): |
| 124 | + return CommonPlatform.WorkspaceRoot |
| 125 | + |
| 126 | + def GetPackagesPath (self): |
| 127 | + result = [ shell_environment.GetBuildVars().GetValue("FEATURE_CONFIG_PATH", "") ] |
| 128 | + |
| 129 | + for a in CommonPlatform.PackagesPath: |
| 130 | + result.append(a) |
| 131 | + |
| 132 | + return result |
| 133 | + |
| 134 | + def GetActiveScopes (self): |
| 135 | + return CommonPlatform.Scopes |
| 136 | + |
| 137 | + def GetName (self): |
| 138 | + return "onyxPkg" |
| 139 | + |
| 140 | + def GetLoggingLevel (self, loggerType): |
| 141 | + return logging.INFO |
| 142 | + return super().GetLoggingLevel(loggerType) |
| 143 | + |
| 144 | + def SetPlatformEnv (self): |
| 145 | + logging.debug ("PlatformBuilder SetPlatformEnv") |
| 146 | + |
| 147 | + self.env.SetValue ("PRODUCT_NAME", "onyx", "Platform Hardcoded") |
| 148 | + self.env.SetValue ("ACTIVE_PLATFORM", "onyxPkg/onyx.dsc", "Platform Hardcoded") |
| 149 | + self.env.SetValue ("TARGET_ARCH", "AARCH64", "Platform Hardcoded") |
| 150 | + self.env.SetValue ("TOOL_CHAIN_TAG", "CLANGPDB", "set default to clangpdb") |
| 151 | + self.env.SetValue ("EMPTY_DRIVE", "FALSE", "Default to false") |
| 152 | + self.env.SetValue ("RUN_TESTS", "FALSE", "Default to false") |
| 153 | + self.env.SetValue ("SHUTDOWN_AFTER_RUN", "FALSE", "Default to false") |
| 154 | + self.env.SetValue ("BLD_*_BUILDID_STRING", "Unknown", "Default") |
| 155 | + self.env.SetValue ("BUILDREPORTING", "TRUE", "Enabling build report") |
| 156 | + self.env.SetValue ("BUILDREPORT_TYPES", "PCD DEPEX FLASH BUILD_FLAGS LIBRARY FIXED_ADDRESS HASH", "Setting build report types") |
| 157 | + self.env.SetValue ("BLD_*_MEMORY_PROTECTION", "TRUE", "Default") |
| 158 | + self.env.SetValue ("BLD_*_SHIP_MODE", "FALSE", "Default") |
| 159 | + self.env.SetValue ("BLD_*_ENABLE_SECUREBOOT", self.env.GetValue("ENABLE_SECUREBOOT"), "Default") |
| 160 | + self.env.SetValue ("BLD_*_FD_BASE", self.env.GetValue("FD_BASE"), "Default") |
| 161 | + self.env.SetValue ("BLD_*_FD_SIZE", self.env.GetValue("FD_SIZE"), "Default") |
| 162 | + self.env.SetValue ("BLD_*_FD_BLOCKS", self.env.GetValue("FD_BLOCKS"), "Default") |
| 163 | + |
| 164 | + return 0 |
| 165 | + |
| 166 | + def PlatformPreBuild (self): |
| 167 | + return 0 |
| 168 | + |
| 169 | + def PlatformPostBuild (self): |
| 170 | + return 0 |
| 171 | + |
| 172 | + def FlashRomImage (self): |
| 173 | + return 0 |
| 174 | + |
| 175 | +if __name__ == "__main__": |
| 176 | + import argparse |
| 177 | + import sys |
| 178 | + |
| 179 | + from edk2toolext.invocables.edk2_platform_build import Edk2PlatformBuild |
| 180 | + from edk2toolext.invocables.edk2_setup import Edk2PlatformSetup |
| 181 | + from edk2toolext.invocables.edk2_update import Edk2Update |
| 182 | + |
| 183 | + SCRIPT_PATH = os.path.relpath (__file__) |
| 184 | + |
| 185 | + parser = argparse.ArgumentParser (add_help=False) |
| 186 | + |
| 187 | + parse_group = parser.add_mutually_exclusive_group() |
| 188 | + |
| 189 | + parse_group.add_argument ("--update", "--UPDATE", action='store_true', help="Invokes stuart_update") |
| 190 | + parse_group.add_argument ("--setup", "--SETUP", action='store_true', help="Invokes stuart_setup") |
| 191 | + |
| 192 | + args, remaining = parser.parse_known_args() |
| 193 | + |
| 194 | + new_args = ["stuart", "-c", SCRIPT_PATH] |
| 195 | + new_args = new_args + remaining |
| 196 | + |
| 197 | + sys.argv = new_args |
| 198 | + |
| 199 | + if args.setup: |
| 200 | + Edk2PlatformSetup().Invoke() |
| 201 | + elif args.update: |
| 202 | + Edk2Update().Invoke() |
| 203 | + else: |
| 204 | + Edk2PlatformBuild().Invoke() |
0 commit comments