microsoft/mu_feature_ffa

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.1.4

Branches

Tags

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

Clone

HTTPS

Download ZIP

.pytool/CISettings.py

206lines · 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 "AARCH64")
62
63 def GetTargetsSupported(self):
64 ''' return iterable of edk2 target tags supported by this build '''
65 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
66
67 # ####################################################################################### #
68 # Verify and Save requested Ci Build Config #
69 # ####################################################################################### #
70
71 def SetPackages(self, list_of_requested_packages):
72 ''' Confirm the requested package list is valid and configure SettingsManager
73 to build the requested packages.
74
75 Raise UnsupportedException if a requested_package is not supported
76 '''
77 unsupported = set(list_of_requested_packages) - \
78 set(self.GetPackagesSupported())
79 if(len(unsupported) > 0):
80 logging.critical(
81 "Unsupported Package Requested: " + " ".join(unsupported))
82 logging.critical(
83 "Supported Packages: " + " ".join(self.GetPackagesSupported()))
84 logging.critical(
85 "Requested Packages: " + " ".join(list_of_requested_packages))
86 raise Exception("Unsupported Package Requested: " +
87 " ".join(unsupported))
88 self.ActualPackages = list_of_requested_packages
89
90 def SetArchitectures(self, list_of_requested_architectures):
91 ''' Confirm the requests architecture list is valid and configure SettingsManager
92 to run only the requested architectures.
93
94 Raise Exception if a list_of_requested_architectures is not supported
95 '''
96 unsupported = set(list_of_requested_architectures) - \
97 set(self.GetArchitecturesSupported())
98 if(len(unsupported) > 0):
99 logging.critical(
100 "Unsupported Architecture Requested: " + " ".join(unsupported))
101 raise Exception(
102 "Unsupported Architecture Requested: " + " ".join(unsupported))
103 self.ActualArchitectures = list_of_requested_architectures
104
105 def SetTargets(self, list_of_requested_target):
106 ''' Confirm the request target list is valid and configure SettingsManager
107 to run only the requested targets.
108
109 Raise UnsupportedException if a requested_target is not supported
110 '''
111 unsupported = set(list_of_requested_target) - \
112 set(self.GetTargetsSupported())
113 if(len(unsupported) > 0):
114 logging.critical(
115 "Unsupported Targets Requested: " + " ".join(unsupported))
116 raise Exception("Unsupported Targets Requested: " +
117 " ".join(unsupported))
118 self.ActualTargets = list_of_requested_target
119
120 # ####################################################################################### #
121 # Actual Configuration for Ci Build #
122 # ####################################################################################### #
123
124 def GetActiveScopes(self):
125 ''' return tuple containing scopes that should be active for this process '''
126 if self.ActualScopes is None:
127 scopes = ("cibuild", "edk2-build", "host-based-test")
128
129 self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
130
131 is_linux = GetHostInfo().os.upper() == "LINUX"
132
133 if is_linux and self.ActualToolChainTag.upper().startswith("GCC"):
134 if "AARCH64" in self.ActualArchitectures:
135 scopes += ("gcc_aarch64_linux",)
136 if "RISCV64" in self.ActualArchitectures:
137 scopes += ("gcc_riscv64_unknown",)
138
139 try:
140 scopes += codeql_helpers.get_scopes(self.codeql)
141
142 if self.codeql:
143 shell_environment.GetBuildVars().SetValue(
144 "STUART_CODEQL_AUDIT_ONLY",
145 "TRUE",
146 "Set in CISettings.py")
147 codeql_filter_files = [str(n) for n in glob.glob(
148 os.path.join(self.GetWorkspaceRoot(),
149 '**/CodeQlFilters.yml'),
150 recursive=True)]
151 shell_environment.GetBuildVars().SetValue(
152 "STUART_CODEQL_FILTER_FILES",
153 ','.join(codeql_filter_files),
154 "Set in CISettings.py")
155 except NameError:
156 pass
157
158 self.ActualScopes = scopes
159 return self.ActualScopes
160
161 def GetRequiredSubmodules(self):
162 ''' return iterable containing RequiredSubmodule objects.
163 If no RequiredSubmodules return an empty iterable
164 '''
165 rs = []
166 return rs
167
168 def GetName(self):
169 return "MuFfaFeature"
170
171 def GetDependencies(self):
172 ''' Return Git Repository Dependencies
173
174 Return an iterable of dictionary objects with the following fields
175 {
176 Path: <required> Workspace relative path
177 Url: <required> Url of git repo
178 Commit: <optional> Commit to checkout of repo
179 Branch: <optional> Branch to checkout (will checkout most recent commit in branch)
180 Full: <optional> Boolean to do shallow or Full checkout. (default is False)
181 ReferencePath: <optional> Workspace relative path to git repo to use as "reference"
182 }
183 '''
184 return [
185 {
186 "Path": "MU_BASECORE",
187 "Url": "https://github.com/microsoft/mu_basecore.git",
188 "Branch": "release/202511",
189 "Recurse": {"CIFile": ".pytool/CISettings.py"}
190 }
191 ]
192
193 def GetPackagesPath(self):
194 ''' Return a list of workspace relative paths that should be mapped as edk2 PackagesPath '''
195 result = []
196 for a in self.GetDependencies():
197 result.append(a["Path"])
198 return result
199
200 def GetWorkspaceRoot(self):
201 ''' get WorkspacePath '''
202 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
203
204 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
205 ''' Filter potential packages to test based on changed files. '''
206 return []
207