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 '''
52 "UnitTestFrameworkPkg"
55 def GetArchitecturesSupported(self
):
56 ''' return iterable of edk2 architectures supported by this build '''
62 def GetTargetsSupported(self
):
63 ''' return iterable of edk2 target tags supported by this build '''
64 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
66 # ####################################################################################### #
67 # Verify and Save requested Ci Build Config #
68 # ####################################################################################### #
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.
74 Raise UnsupportedException if a requested_package is not supported
76 unsupported
= set(list_of_requested_packages
) - \
77 set(self
.GetPackagesSupported())
78 if(len(unsupported
) > 0):
80 "Unsupported Package Requested: " + " ".join(unsupported
))
81 raise Exception("Unsupported Package Requested: " +
82 " ".join(unsupported
))
83 self
.ActualPackages
= list_of_requested_packages
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.
89 Raise Exception if a list_of_requested_architectures is not supported
91 unsupported
= set(list_of_requested_architectures
) - \
92 set(self
.GetArchitecturesSupported())
93 if(len(unsupported
) > 0):
95 "Unsupported Architecture Requested: " + " ".join(unsupported
))
97 "Unsupported Architecture Requested: " + " ".join(unsupported
))
98 self
.ActualArchitectures
= list_of_requested_architectures
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.
104 Raise UnsupportedException if a requested_target is not supported
106 unsupported
= set(list_of_requested_target
) - \
107 set(self
.GetTargetsSupported())
108 if(len(unsupported
) > 0):
110 "Unsupported Targets Requested: " + " ".join(unsupported
))
111 raise Exception("Unsupported Targets Requested: " +
112 " ".join(unsupported
))
113 self
.ActualTargets
= list_of_requested_target
115 # ####################################################################################### #
116 # Actual Configuration for Ci Build #
117 # ####################################################################################### #
119 def GetActiveScopes(self
):
120 ''' return tuple containing scopes that should be active for this process '''
121 scopes
= ("cibuild", "edk2-build", "host-based-test")
123 self
.ActualToolChainTag
= shell_environment
.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
125 if GetHostInfo().os
.upper() == "WINDOWS":
126 scopes
+= ('host-test-win',)
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",)
136 def GetRequiredSubmodules(self
):
137 ''' return iterable containing RequiredSubmodule objects.
138 If no RequiredSubmodules return an empty iterable
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))
152 def GetDependencies(self
):
156 def GetPackagesPath(self
):
159 def GetWorkspaceRoot(self
):
160 ''' get WorkspacePath '''
161 return os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
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
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
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
181 return build_these_packages