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 def GetArchitecturesSupported(self
):
55 ''' return iterable of edk2 architectures supported by this build '''
61 def GetTargetsSupported(self
):
62 ''' return iterable of edk2 target tags supported by this build '''
63 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
65 # ####################################################################################### #
66 # Verify and Save requested Ci Build Config #
67 # ####################################################################################### #
69 def SetPackages(self
, list_of_requested_packages
):
70 ''' Confirm the requested package list is valid and configure SettingsManager
71 to build the requested packages.
73 Raise UnsupportedException if a requested_package is not supported
75 unsupported
= set(list_of_requested_packages
) - \
76 set(self
.GetPackagesSupported())
77 if(len(unsupported
) > 0):
79 "Unsupported Package Requested: " + " ".join(unsupported
))
80 raise Exception("Unsupported Package Requested: " +
81 " ".join(unsupported
))
82 self
.ActualPackages
= list_of_requested_packages
84 def SetArchitectures(self
, list_of_requested_architectures
):
85 ''' Confirm the requests architecture list is valid and configure SettingsManager
86 to run only the requested architectures.
88 Raise Exception if a list_of_requested_architectures is not supported
90 unsupported
= set(list_of_requested_architectures
) - \
91 set(self
.GetArchitecturesSupported())
92 if(len(unsupported
) > 0):
94 "Unsupported Architecture Requested: " + " ".join(unsupported
))
96 "Unsupported Architecture Requested: " + " ".join(unsupported
))
97 self
.ActualArchitectures
= list_of_requested_architectures
99 def SetTargets(self
, list_of_requested_target
):
100 ''' Confirm the request target list is valid and configure SettingsManager
101 to run only the requested targets.
103 Raise UnsupportedException if a requested_target is not supported
105 unsupported
= set(list_of_requested_target
) - \
106 set(self
.GetTargetsSupported())
107 if(len(unsupported
) > 0):
109 "Unsupported Targets Requested: " + " ".join(unsupported
))
110 raise Exception("Unsupported Targets Requested: " +
111 " ".join(unsupported
))
112 self
.ActualTargets
= list_of_requested_target
114 # ####################################################################################### #
115 # Actual Configuration for Ci Build #
116 # ####################################################################################### #
118 def GetActiveScopes(self
):
119 ''' return tuple containing scopes that should be active for this process '''
120 scopes
= ("cibuild","edk2-build")
122 self
.ActualToolChainTag
= shell_environment
.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
124 if GetHostInfo().os
.upper() == "LINUX" and self
.ActualToolChainTag
.upper().startswith("GCC"):
125 if "AARCH64" in self
.ActualArchitectures
:
126 scopes
+= ("gcc_aarch64_linux",)
127 if "ARM" in self
.ActualArchitectures
:
128 scopes
+= ("gcc_arm_linux",)
132 def GetRequiredSubmodules(self
):
133 ''' return iterable containing RequiredSubmodule objects.
134 If no RequiredSubmodules return an empty iterable
137 rs
.append(RequiredSubmodule(
138 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
139 rs
.append(RequiredSubmodule(
140 "CryptoPkg/Library/OpensslLib/openssl", False))
146 def GetDependencies(self
):
149 def GetPackagesPath(self
):
152 def GetWorkspaceRoot(self
):
153 ''' get WorkspacePath '''
154 return os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
156 def FilterPackagesToTest(self
, changedFilesList
: list, potentialPackagesList
: list) -> list:
157 ''' Filter potential packages to test based on changed files. '''
158 build_these_packages
=[]
159 possible_packages
=potentialPackagesList
.copy()
160 for f
in changedFilesList
:
161 nodes
=f
.split("/") # split each part of path for comparison later
163 # python file change in .pytool folder causes building all
164 if f
.endswith(".py") and ".pytool" in nodes
:
165 build_these_packages
= possible_packages
168 # BaseTools files that might change the build
169 if "BaseTools" in nodes
:
170 if os
.path
.splitext(f
) not in [".txt", ".md"]:
171 build_these_packages
= possible_packages
173 return build_these_packages