microsoft/mu_feature_ffa

Public

mirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3d4b142bc3f2df66be0148459e45a92d4a1edf2c

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.pytool/CISettings.py

218lines · modecode

1# @file
2#
3# Copyright (c) Microsoft Corporation. All rights reserved.
4# SPDX-License-Identifier: BSD-2-Clause-Patent
5##
6import glob
7import os
8import logging
9from edk2toolext.environment import shell_environment
10from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
11from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager
12from edk2toolext.invocables.edk2_setup import SetupSettingsManager
13from edk2toolext.invocables.edk2_update import UpdateSettingsManager
14from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
15from edk2toollib.utility_functions import GetHostInfo
16
17from edk2toolext import codeql as codeql_helpers
18
19class Settings(CiSetupSettingsManager, CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
20
21 def __init__(self):
22 self.ActualPackages = []
23 self.ActualTargets = []
24 self.ActualArchitectures = []
25 self.ActualToolChainTag = ""
26 self.ActualScopes = None
27
28 # ####################################################################################### #
29 # Extra CmdLine configuration #
30 # ####################################################################################### #
31
32 def AddCommandLineOptions(self, parserObj):
33 try:
34 codeql_helpers.add_command_line_option(parserObj)
35 except NameError:
36 pass
37
38 def RetrieveCommandLineOptions(self, args):
39 super().RetrieveCommandLineOptions(args)
40 try:
41 self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args)
42 except NameError:
43 pass
44
45 # ####################################################################################### #
46 # Default Support for this Ci Build #
47 # ####################################################################################### #
48
49 def GetPackagesSupported(self):
50 ''' return iterable of edk2 packages supported by this build.
51 These should be edk2 workspace relative paths '''
52
53 return (
54 "FfaFeaturePkg",
55 )
56
57 def GetArchitecturesSupported(self):
58 ''' return iterable of edk2 architectures supported by this build '''
59 return ("IA32",
60 "X64",
61 "ARM",
62 "AARCH64")
63
64 def GetTargetsSupported(self):
65 ''' return iterable of edk2 target tags supported by this build '''
66 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
67
68 # ####################################################################################### #
69 # Verify and Save requested Ci Build Config #
70 # ####################################################################################### #
71
72 def SetPackages(self, list_of_requested_packages):
73 ''' Confirm the requested package list is valid and configure SettingsManager
74 to build the requested packages.
75
76 Raise UnsupportedException if a requested_package is not supported
77 '''
78 unsupported = set(list_of_requested_packages) - \
79 set(self.GetPackagesSupported())
80 if(len(unsupported) > 0):
81 logging.critical(
82 "Unsupported Package Requested: " + " ".join(unsupported))
83 logging.critical(
84 "Supported Packages: " + " ".join(self.GetPackagesSupported()))
85 logging.critical(
86 "Requested Packages: " + " ".join(list_of_requested_packages))
87 raise Exception("Unsupported Package Requested: " +
88 " ".join(unsupported))
89 self.ActualPackages = list_of_requested_packages
90
91 def SetArchitectures(self, list_of_requested_architectures):
92 ''' Confirm the requests architecture list is valid and configure SettingsManager
93 to run only the requested architectures.
94
95 Raise Exception if a list_of_requested_architectures is not supported
96 '''
97 unsupported = set(list_of_requested_architectures) - \
98 set(self.GetArchitecturesSupported())
99 if(len(unsupported) > 0):
100 logging.critical(
101 "Unsupported Architecture Requested: " + " ".join(unsupported))
102 raise Exception(
103 "Unsupported Architecture Requested: " + " ".join(unsupported))
104 self.ActualArchitectures = list_of_requested_architectures
105
106 def SetTargets(self, list_of_requested_target):
107 ''' Confirm the request target list is valid and configure SettingsManager
108 to run only the requested targets.
109
110 Raise UnsupportedException if a requested_target is not supported
111 '''
112 unsupported = set(list_of_requested_target) - \
113 set(self.GetTargetsSupported())
114 if(len(unsupported) > 0):
115 logging.critical(
116 "Unsupported Targets Requested: " + " ".join(unsupported))
117 raise Exception("Unsupported Targets Requested: " +
118 " ".join(unsupported))
119 self.ActualTargets = list_of_requested_target
120
121 # ####################################################################################### #
122 # Actual Configuration for Ci Build #
123 # ####################################################################################### #
124
125 def GetActiveScopes(self):
126 ''' return tuple containing scopes that should be active for this process '''
127 if self.ActualScopes is None:
128 scopes = ("cibuild", "edk2-build", "host-based-test")
129
130 self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
131
132 is_linux = GetHostInfo().os.upper() == "LINUX"
133
134 if is_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 try:
143 scopes += codeql_helpers.get_scopes(self.codeql)
144
145 if self.codeql:
146 shell_environment.GetBuildVars().SetValue(
147 "STUART_CODEQL_AUDIT_ONLY",
148 "TRUE",
149 "Set in CISettings.py")
150 codeql_filter_files = [str(n) for n in glob.glob(
151 os.path.join(self.GetWorkspaceRoot(),
152 '**/CodeQlFilters.yml'),
153 recursive=True)]
154 shell_environment.GetBuildVars().SetValue(
155 "STUART_CODEQL_FILTER_FILES",
156 ','.join(codeql_filter_files),
157 "Set in CISettings.py")
158 except NameError:
159 pass
160
161 self.ActualScopes = scopes
162 return self.ActualScopes
163
164 def GetRequiredSubmodules(self):
165 ''' return iterable containing RequiredSubmodule objects.
166 If no RequiredSubmodules return an empty iterable
167 '''
168 rs = []
169 return rs
170
171 def GetName(self):
172 return "MuFfaFeature"
173
174 def GetDependencies(self):
175 ''' Return Git Repository Dependencies
176
177 Return an iterable of dictionary objects with the following fields
178 {
179 Path: <required> Workspace relative path
180 Url: <required> Url of git repo
181 Commit: <optional> Commit to checkout of repo
182 Branch: <optional> Branch to checkout (will checkout most recent commit in branch)
183 Full: <optional> Boolean to do shallow or Full checkout. (default is False)
184 ReferencePath: <optional> Workspace relative path to git repo to use as "reference"
185 }
186 '''
187 return [
188 {
189 "Path": "MU_BASECORE",
190 "Url": "https://github.com/microsoft/mu_basecore.git",
191 "Branch": "dev/202502"
192 },
193 {
194 "Path": "Silicon/Arm/MU_TIANO",
195 "Url": "https://github.com/Microsoft/mu_silicon_arm_tiano.git",
196 "Branch": "dev/202502"
197 },
198 {
199 "Path": "Common/MU_TIANO",
200 "Url": "https://github.com/Microsoft/mu_tiano_plus.git",
201 "Branch": "dev/202502"
202 }
203 ]
204
205 def GetPackagesPath(self):
206 ''' Return a list of workspace relative paths that should be mapped as edk2 PackagesPath '''
207 result = []
208 for a in self.GetDependencies():
209 result.append(a["Path"])
210 return result
211
212 def GetWorkspaceRoot(self):
213 ''' get WorkspacePath '''
214 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
215
216 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
217 ''' Filter potential packages to test based on changed files. '''
218 return []
219