1 | # @file
|
---|
2 | #
|
---|
3 | # Copyright (c) Microsoft Corporation.
|
---|
4 | # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
---|
5 | # SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 | ##
|
---|
7 | import os
|
---|
8 | import logging
|
---|
9 | from edk2toolext.environment import shell_environment
|
---|
10 | from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
|
---|
11 | from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubmodule
|
---|
12 | from edk2toolext.invocables.edk2_update import UpdateSettingsManager
|
---|
13 | from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
|
---|
14 | from edk2toollib.utility_functions import GetHostInfo
|
---|
15 |
|
---|
16 |
|
---|
17 | class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
|
---|
18 |
|
---|
19 | def __init__(self):
|
---|
20 | self.ActualPackages = []
|
---|
21 | self.ActualTargets = []
|
---|
22 | self.ActualArchitectures = []
|
---|
23 | self.ActualToolChainTag = ""
|
---|
24 |
|
---|
25 | # ####################################################################################### #
|
---|
26 | # Extra CmdLine configuration #
|
---|
27 | # ####################################################################################### #
|
---|
28 |
|
---|
29 | def AddCommandLineOptions(self, parserObj):
|
---|
30 | pass
|
---|
31 |
|
---|
32 | def RetrieveCommandLineOptions(self, args):
|
---|
33 | pass
|
---|
34 |
|
---|
35 | # ####################################################################################### #
|
---|
36 | # Default Support for this Ci Build #
|
---|
37 | # ####################################################################################### #
|
---|
38 |
|
---|
39 | def GetPackagesSupported(self):
|
---|
40 | ''' return iterable of edk2 packages supported by this build.
|
---|
41 | These should be edk2 workspace relative paths '''
|
---|
42 |
|
---|
43 | return ("ArmVirtPkg",
|
---|
44 | "EmulatorPkg",
|
---|
45 | "MdePkg",
|
---|
46 | "MdeModulePkg",
|
---|
47 | "NetworkPkg",
|
---|
48 | "PcAtChipsetPkg",
|
---|
49 | "SecurityPkg",
|
---|
50 | "UefiCpuPkg",
|
---|
51 | "FmpDevicePkg",
|
---|
52 | "ShellPkg",
|
---|
53 | "FatPkg",
|
---|
54 | "CryptoPkg",
|
---|
55 | "UnitTestFrameworkPkg",
|
---|
56 | "OvmfPkg"
|
---|
57 | )
|
---|
58 |
|
---|
59 | def GetArchitecturesSupported(self):
|
---|
60 | ''' return iterable of edk2 architectures supported by this build '''
|
---|
61 | return (
|
---|
62 | "IA32",
|
---|
63 | "X64",
|
---|
64 | "ARM",
|
---|
65 | "AARCH64",
|
---|
66 | "RISCV64")
|
---|
67 |
|
---|
68 | def GetTargetsSupported(self):
|
---|
69 | ''' return iterable of edk2 target tags supported by this build '''
|
---|
70 | return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
|
---|
71 |
|
---|
72 | # ####################################################################################### #
|
---|
73 | # Verify and Save requested Ci Build Config #
|
---|
74 | # ####################################################################################### #
|
---|
75 |
|
---|
76 | def SetPackages(self, list_of_requested_packages):
|
---|
77 | ''' Confirm the requested package list is valid and configure SettingsManager
|
---|
78 | to build the requested packages.
|
---|
79 |
|
---|
80 | Raise UnsupportedException if a requested_package is not supported
|
---|
81 | '''
|
---|
82 | unsupported = set(list_of_requested_packages) - \
|
---|
83 | set(self.GetPackagesSupported())
|
---|
84 | if(len(unsupported) > 0):
|
---|
85 | logging.critical(
|
---|
86 | "Unsupported Package Requested: " + " ".join(unsupported))
|
---|
87 | raise Exception("Unsupported Package Requested: " +
|
---|
88 | " ".join(unsupported))
|
---|
89 | self.ActualPackages = list_of_requested_packages
|
---|
90 |
|
---|
91 | def SetArchitectures(self, list_of_requested_architectures):
|
---|
92 | ''' Confirm the requests architecture list is valid and configure SettingsManager
|
---|
93 | to run only the requested architectures.
|
---|
94 |
|
---|
95 | Raise Exception if a list_of_requested_architectures is not supported
|
---|
96 | '''
|
---|
97 | unsupported = set(list_of_requested_architectures) - \
|
---|
98 | set(self.GetArchitecturesSupported())
|
---|
99 | if(len(unsupported) > 0):
|
---|
100 | logging.critical(
|
---|
101 | "Unsupported Architecture Requested: " + " ".join(unsupported))
|
---|
102 | raise Exception(
|
---|
103 | "Unsupported Architecture Requested: " + " ".join(unsupported))
|
---|
104 | self.ActualArchitectures = list_of_requested_architectures
|
---|
105 |
|
---|
106 | def SetTargets(self, list_of_requested_target):
|
---|
107 | ''' Confirm the request target list is valid and configure SettingsManager
|
---|
108 | to run only the requested targets.
|
---|
109 |
|
---|
110 | Raise UnsupportedException if a requested_target is not supported
|
---|
111 | '''
|
---|
112 | unsupported = set(list_of_requested_target) - \
|
---|
113 | set(self.GetTargetsSupported())
|
---|
114 | if(len(unsupported) > 0):
|
---|
115 | logging.critical(
|
---|
116 | "Unsupported Targets Requested: " + " ".join(unsupported))
|
---|
117 | raise Exception("Unsupported Targets Requested: " +
|
---|
118 | " ".join(unsupported))
|
---|
119 | self.ActualTargets = list_of_requested_target
|
---|
120 |
|
---|
121 | # ####################################################################################### #
|
---|
122 | # Actual Configuration for Ci Build #
|
---|
123 | # ####################################################################################### #
|
---|
124 |
|
---|
125 | def GetActiveScopes(self):
|
---|
126 | ''' return tuple containing scopes that should be active for this process '''
|
---|
127 | scopes = ("cibuild", "edk2-build", "host-based-test")
|
---|
128 |
|
---|
129 | self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
|
---|
130 |
|
---|
131 | if GetHostInfo().os.upper() == "LINUX" and self.ActualToolChainTag.upper().startswith("GCC"):
|
---|
132 | if "AARCH64" in self.ActualArchitectures:
|
---|
133 | scopes += ("gcc_aarch64_linux",)
|
---|
134 | if "ARM" in self.ActualArchitectures:
|
---|
135 | scopes += ("gcc_arm_linux",)
|
---|
136 | if "RISCV64" in self.ActualArchitectures:
|
---|
137 | scopes += ("gcc_riscv64_unknown",)
|
---|
138 |
|
---|
139 | return scopes
|
---|
140 |
|
---|
141 | def GetRequiredSubmodules(self):
|
---|
142 | ''' return iterable containing RequiredSubmodule objects.
|
---|
143 | If no RequiredSubmodules return an empty iterable
|
---|
144 | '''
|
---|
145 | rs = []
|
---|
146 | rs.append(RequiredSubmodule(
|
---|
147 | "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
|
---|
148 | rs.append(RequiredSubmodule(
|
---|
149 | "CryptoPkg/Library/OpensslLib/openssl", False))
|
---|
150 | rs.append(RequiredSubmodule(
|
---|
151 | "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
|
---|
152 | rs.append(RequiredSubmodule(
|
---|
153 | "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
|
---|
154 | rs.append(RequiredSubmodule(
|
---|
155 | "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli", False))
|
---|
156 | rs.append(RequiredSubmodule(
|
---|
157 | "BaseTools/Source/C/BrotliCompress/brotli", False))
|
---|
158 | return rs
|
---|
159 |
|
---|
160 | def GetName(self):
|
---|
161 | return "Edk2"
|
---|
162 |
|
---|
163 | def GetDependencies(self):
|
---|
164 | return [
|
---|
165 | ]
|
---|
166 |
|
---|
167 | def GetPackagesPath(self):
|
---|
168 | return ()
|
---|
169 |
|
---|
170 | def GetWorkspaceRoot(self):
|
---|
171 | ''' get WorkspacePath '''
|
---|
172 | return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
---|
173 |
|
---|
174 | def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
|
---|
175 | ''' Filter potential packages to test based on changed files. '''
|
---|
176 | build_these_packages = []
|
---|
177 | possible_packages = potentialPackagesList.copy()
|
---|
178 | for f in changedFilesList:
|
---|
179 | # split each part of path for comparison later
|
---|
180 | nodes = f.split("/")
|
---|
181 |
|
---|
182 | # python file change in .pytool folder causes building all
|
---|
183 | if f.endswith(".py") and ".pytool" in nodes:
|
---|
184 | build_these_packages = possible_packages
|
---|
185 | break
|
---|
186 |
|
---|
187 | # BaseTools files that might change the build
|
---|
188 | if "BaseTools" in nodes:
|
---|
189 | if os.path.splitext(f) not in [".txt", ".md"]:
|
---|
190 | build_these_packages = possible_packages
|
---|
191 | break
|
---|
192 | return build_these_packages
|
---|