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