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