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