3 # Copyright (c) Microsoft Corporation.
4 # SPDX-License-Identifier: BSD-2-Clause-Patent
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
16 class Settings(CiBuildSettingsManager
, UpdateSettingsManager
, SetupSettingsManager
, PrEvalSettingsManager
):
19 self
.ActualPackages
= []
20 self
.ActualTargets
= []
21 self
.ActualArchitectures
= []
22 self
.ActualToolChainTag
= ""
24 # ####################################################################################### #
25 # Extra CmdLine configuration #
26 # ####################################################################################### #
28 def AddCommandLineOptions(self
, parserObj
):
31 def RetrieveCommandLineOptions(self
, args
):
34 # ####################################################################################### #
35 # Default Support for this Ci Build #
36 # ####################################################################################### #
38 def GetPackagesSupported(self
):
39 ''' return iterable of edk2 packages supported by this build.
40 These should be edk2 workspace relative paths '''
54 "UnitTestFrameworkPkg",
58 def GetArchitecturesSupported(self
):
59 ''' return iterable of edk2 architectures supported by this build '''
65 def GetTargetsSupported(self
):
66 ''' return iterable of edk2 target tags supported by this build '''
67 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
69 # ####################################################################################### #
70 # Verify and Save requested Ci Build Config #
71 # ####################################################################################### #
73 def SetPackages(self
, list_of_requested_packages
):
74 ''' Confirm the requested package list is valid and configure SettingsManager
75 to build the requested packages.
77 Raise UnsupportedException if a requested_package is not supported
79 unsupported
= set(list_of_requested_packages
) - \
80 set(self
.GetPackagesSupported())
81 if(len(unsupported
) > 0):
83 "Unsupported Package Requested: " + " ".join(unsupported
))
84 raise Exception("Unsupported Package Requested: " +
85 " ".join(unsupported
))
86 self
.ActualPackages
= list_of_requested_packages
88 def SetArchitectures(self
, list_of_requested_architectures
):
89 ''' Confirm the requests architecture list is valid and configure SettingsManager
90 to run only the requested architectures.
92 Raise Exception if a list_of_requested_architectures is not supported
94 unsupported
= set(list_of_requested_architectures
) - \
95 set(self
.GetArchitecturesSupported())
96 if(len(unsupported
) > 0):
98 "Unsupported Architecture Requested: " + " ".join(unsupported
))
100 "Unsupported Architecture Requested: " + " ".join(unsupported
))
101 self
.ActualArchitectures
= list_of_requested_architectures
103 def SetTargets(self
, list_of_requested_target
):
104 ''' Confirm the request target list is valid and configure SettingsManager
105 to run only the requested targets.
107 Raise UnsupportedException if a requested_target is not supported
109 unsupported
= set(list_of_requested_target
) - \
110 set(self
.GetTargetsSupported())
111 if(len(unsupported
) > 0):
113 "Unsupported Targets Requested: " + " ".join(unsupported
))
114 raise Exception("Unsupported Targets Requested: " +
115 " ".join(unsupported
))
116 self
.ActualTargets
= list_of_requested_target
118 # ####################################################################################### #
119 # Actual Configuration for Ci Build #
120 # ####################################################################################### #
122 def GetActiveScopes(self
):
123 ''' return tuple containing scopes that should be active for this process '''
124 scopes
= ("cibuild", "edk2-build", "host-based-test")
126 self
.ActualToolChainTag
= shell_environment
.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
128 if GetHostInfo().os
.upper() == "WINDOWS":
129 scopes
+= ('host-test-win',)
131 if GetHostInfo().os
.upper() == "LINUX" and self
.ActualToolChainTag
.upper().startswith("GCC"):
132 if "AARCH64" in self
.ActualArchitectures
:
133 scopes
+= ("gcc_aarch64_linux",)
134 if "ARM" in self
.ActualArchitectures
:
135 scopes
+= ("gcc_arm_linux",)
139 def GetRequiredSubmodules(self
):
140 ''' return iterable containing RequiredSubmodule objects.
141 If no RequiredSubmodules return an empty iterable
144 rs
.append(RequiredSubmodule(
145 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
146 rs
.append(RequiredSubmodule(
147 "CryptoPkg/Library/OpensslLib/openssl", False))
148 rs
.append(RequiredSubmodule(
149 "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
150 rs
.append(RequiredSubmodule(
151 "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
152 rs
.append(RequiredSubmodule(
153 "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli", False))
154 rs
.append(RequiredSubmodule(
155 "BaseTools/Source/C/BrotliCompress/brotli", False))
161 def GetDependencies(self
):
165 def GetPackagesPath(self
):
168 def GetWorkspaceRoot(self
):
169 ''' get WorkspacePath '''
170 return os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
172 def FilterPackagesToTest(self
, changedFilesList
: list, potentialPackagesList
: list) -> list:
173 ''' Filter potential packages to test based on changed files. '''
174 build_these_packages
= []
175 possible_packages
= potentialPackagesList
.copy()
176 for f
in changedFilesList
:
177 # split each part of path for comparison later
180 # python file change in .pytool folder causes building all
181 if f
.endswith(".py") and ".pytool" in nodes
:
182 build_these_packages
= possible_packages
185 # BaseTools files that might change the build
186 if "BaseTools" in nodes
:
187 if os
.path
.splitext(f
) not in [".txt", ".md"]:
188 build_these_packages
= possible_packages
190 return build_these_packages