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