]> git.proxmox.com Git - mirror_edk2.git/blob - .pytool/CISettings.py
SourceLevelDebugPkg: Fix spelling errors
[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 "EmbeddedPkg",
57 "EmulatorPkg",
58 "IntelFsp2Pkg",
59 "IntelFsp2WrapperPkg",
60 "MdePkg",
61 "MdeModulePkg",
62 "NetworkPkg",
63 "PcAtChipsetPkg",
64 "SecurityPkg",
65 "UefiCpuPkg",
66 "FmpDevicePkg",
67 "ShellPkg",
68 "SignedCapsulePkg",
69 "StandaloneMmPkg",
70 "FatPkg",
71 "CryptoPkg",
72 "PrmPkg",
73 "UnitTestFrameworkPkg",
74 "OvmfPkg",
75 "RedfishPkg",
76 "UefiPayloadPkg"
77 )
78
79 def GetArchitecturesSupported(self):
80 ''' return iterable of edk2 architectures supported by this build '''
81 return (
82 "IA32",
83 "X64",
84 "ARM",
85 "AARCH64",
86 "RISCV64")
87
88 def GetTargetsSupported(self):
89 ''' return iterable of edk2 target tags supported by this build '''
90 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
91
92 # ####################################################################################### #
93 # Verify and Save requested Ci Build Config #
94 # ####################################################################################### #
95
96 def SetPackages(self, list_of_requested_packages):
97 ''' Confirm the requested package list is valid and configure SettingsManager
98 to build the requested packages.
99
100 Raise UnsupportedException if a requested_package is not supported
101 '''
102 unsupported = set(list_of_requested_packages) - \
103 set(self.GetPackagesSupported())
104 if(len(unsupported) > 0):
105 logging.critical(
106 "Unsupported Package Requested: " + " ".join(unsupported))
107 raise Exception("Unsupported Package Requested: " +
108 " ".join(unsupported))
109 self.ActualPackages = list_of_requested_packages
110
111 def SetArchitectures(self, list_of_requested_architectures):
112 ''' Confirm the requests architecture list is valid and configure SettingsManager
113 to run only the requested architectures.
114
115 Raise Exception if a list_of_requested_architectures is not supported
116 '''
117 unsupported = set(list_of_requested_architectures) - \
118 set(self.GetArchitecturesSupported())
119 if(len(unsupported) > 0):
120 logging.critical(
121 "Unsupported Architecture Requested: " + " ".join(unsupported))
122 raise Exception(
123 "Unsupported Architecture Requested: " + " ".join(unsupported))
124 self.ActualArchitectures = list_of_requested_architectures
125
126 def SetTargets(self, list_of_requested_target):
127 ''' Confirm the request target list is valid and configure SettingsManager
128 to run only the requested targets.
129
130 Raise UnsupportedException if a requested_target is not supported
131 '''
132 unsupported = set(list_of_requested_target) - \
133 set(self.GetTargetsSupported())
134 if(len(unsupported) > 0):
135 logging.critical(
136 "Unsupported Targets Requested: " + " ".join(unsupported))
137 raise Exception("Unsupported Targets Requested: " +
138 " ".join(unsupported))
139 self.ActualTargets = list_of_requested_target
140
141 # ####################################################################################### #
142 # Actual Configuration for Ci Build #
143 # ####################################################################################### #
144
145 def GetActiveScopes(self):
146 ''' return tuple containing scopes that should be active for this process '''
147 if self.ActualScopes is None:
148 scopes = ("cibuild", "edk2-build", "host-based-test")
149
150 self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
151
152 is_linux = GetHostInfo().os.upper() == "LINUX"
153
154 if self.UseBuiltInBaseTools is None:
155 is_linux = GetHostInfo().os.upper() == "LINUX"
156 # try and import the pip module for basetools
157 try:
158 import edk2basetools
159 self.UseBuiltInBaseTools = True
160 except ImportError:
161 self.UseBuiltInBaseTools = False
162 pass
163
164 if self.UseBuiltInBaseTools == True:
165 scopes += ('pipbuild-unix',) if is_linux else ('pipbuild-win',)
166 logging.warning("Using Pip Tools based BaseTools")
167 else:
168 logging.warning("Falling back to using in-tree BaseTools")
169
170 if is_linux and self.ActualToolChainTag.upper().startswith("GCC"):
171 if "AARCH64" in self.ActualArchitectures:
172 scopes += ("gcc_aarch64_linux",)
173 if "ARM" in self.ActualArchitectures:
174 scopes += ("gcc_arm_linux",)
175 if "RISCV64" in self.ActualArchitectures:
176 scopes += ("gcc_riscv64_unknown",)
177 self.ActualScopes = scopes
178 return self.ActualScopes
179
180 def GetRequiredSubmodules(self):
181 ''' return iterable containing RequiredSubmodule objects.
182 If no RequiredSubmodules return an empty iterable
183 '''
184 rs = []
185 rs.append(RequiredSubmodule(
186 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
187 rs.append(RequiredSubmodule(
188 "CryptoPkg/Library/OpensslLib/openssl", False))
189 rs.append(RequiredSubmodule(
190 "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
191 rs.append(RequiredSubmodule(
192 "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
193 rs.append(RequiredSubmodule(
194 "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli", False))
195 rs.append(RequiredSubmodule(
196 "BaseTools/Source/C/BrotliCompress/brotli", False))
197 rs.append(RequiredSubmodule(
198 "RedfishPkg/Library/JsonLib/jansson", False))
199 return rs
200
201 def GetName(self):
202 return "Edk2"
203
204 def GetDependencies(self):
205 return [
206 ]
207
208 def GetPackagesPath(self):
209 return ()
210
211 def GetWorkspaceRoot(self):
212 ''' get WorkspacePath '''
213 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
214
215 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
216 ''' Filter potential packages to test based on changed files. '''
217 build_these_packages = []
218 possible_packages = potentialPackagesList.copy()
219 for f in changedFilesList:
220 # split each part of path for comparison later
221 nodes = f.split("/")
222
223 # python file change in .pytool folder causes building all
224 if f.endswith(".py") and ".pytool" in nodes:
225 build_these_packages = possible_packages
226 break
227
228 # BaseTools files that might change the build
229 if "BaseTools" in nodes:
230 if os.path.splitext(f) not in [".txt", ".md"]:
231 build_these_packages = possible_packages
232 break
233 return build_these_packages