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