]> git.proxmox.com Git - mirror_edk2.git/blob - .pytool/CISettings.py
OvmfPkg: add 'initrd' shell command to expose Linux initrd via device path
[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 return rs
148
149 def GetName(self):
150 return "Edk2"
151
152 def GetDependencies(self):
153 return [
154 ]
155
156 def GetPackagesPath(self):
157 return ()
158
159 def GetWorkspaceRoot(self):
160 ''' get WorkspacePath '''
161 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
162
163 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
164 ''' Filter potential packages to test based on changed files. '''
165 build_these_packages = []
166 possible_packages = potentialPackagesList.copy()
167 for f in changedFilesList:
168 # split each part of path for comparison later
169 nodes = f.split("/")
170
171 # python file change in .pytool folder causes building all
172 if f.endswith(".py") and ".pytool" in nodes:
173 build_these_packages = possible_packages
174 break
175
176 # BaseTools files that might change the build
177 if "BaseTools" in nodes:
178 if os.path.splitext(f) not in [".txt", ".md"]:
179 build_these_packages = possible_packages
180 break
181 return build_these_packages