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