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