3 # Copyright (c) Microsoft Corporation.
4 # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
5 # Copyright (c) 2020, ARM Limited. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
10 from edk2toolext
.environment
import shell_environment
11 from edk2toolext
.invocables
.edk2_ci_build
import CiBuildSettingsManager
12 from edk2toolext
.invocables
.edk2_setup
import SetupSettingsManager
, RequiredSubmodule
13 from edk2toolext
.invocables
.edk2_update
import UpdateSettingsManager
14 from edk2toolext
.invocables
.edk2_pr_eval
import PrEvalSettingsManager
15 from edk2toollib
.utility_functions
import GetHostInfo
18 class Settings(CiBuildSettingsManager
, UpdateSettingsManager
, SetupSettingsManager
, PrEvalSettingsManager
):
21 self
.ActualPackages
= []
22 self
.ActualTargets
= []
23 self
.ActualArchitectures
= []
24 self
.ActualToolChainTag
= ""
26 # ####################################################################################### #
27 # Extra CmdLine configuration #
28 # ####################################################################################### #
30 def AddCommandLineOptions(self
, parserObj
):
33 def RetrieveCommandLineOptions(self
, args
):
36 # ####################################################################################### #
37 # Default Support for this Ci Build #
38 # ####################################################################################### #
40 def GetPackagesSupported(self
):
41 ''' return iterable of edk2 packages supported by this build.
42 These should be edk2 workspace relative paths '''
57 "UnitTestFrameworkPkg",
61 def GetArchitecturesSupported(self
):
62 ''' return iterable of edk2 architectures supported by this build '''
70 def GetTargetsSupported(self
):
71 ''' return iterable of edk2 target tags supported by this build '''
72 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
74 # ####################################################################################### #
75 # Verify and Save requested Ci Build Config #
76 # ####################################################################################### #
78 def SetPackages(self
, list_of_requested_packages
):
79 ''' Confirm the requested package list is valid and configure SettingsManager
80 to build the requested packages.
82 Raise UnsupportedException if a requested_package is not supported
84 unsupported
= set(list_of_requested_packages
) - \
85 set(self
.GetPackagesSupported())
86 if(len(unsupported
) > 0):
88 "Unsupported Package Requested: " + " ".join(unsupported
))
89 raise Exception("Unsupported Package Requested: " +
90 " ".join(unsupported
))
91 self
.ActualPackages
= list_of_requested_packages
93 def SetArchitectures(self
, list_of_requested_architectures
):
94 ''' Confirm the requests architecture list is valid and configure SettingsManager
95 to run only the requested architectures.
97 Raise Exception if a list_of_requested_architectures is not supported
99 unsupported
= set(list_of_requested_architectures
) - \
100 set(self
.GetArchitecturesSupported())
101 if(len(unsupported
) > 0):
103 "Unsupported Architecture Requested: " + " ".join(unsupported
))
105 "Unsupported Architecture Requested: " + " ".join(unsupported
))
106 self
.ActualArchitectures
= list_of_requested_architectures
108 def SetTargets(self
, list_of_requested_target
):
109 ''' Confirm the request target list is valid and configure SettingsManager
110 to run only the requested targets.
112 Raise UnsupportedException if a requested_target is not supported
114 unsupported
= set(list_of_requested_target
) - \
115 set(self
.GetTargetsSupported())
116 if(len(unsupported
) > 0):
118 "Unsupported Targets Requested: " + " ".join(unsupported
))
119 raise Exception("Unsupported Targets Requested: " +
120 " ".join(unsupported
))
121 self
.ActualTargets
= list_of_requested_target
123 # ####################################################################################### #
124 # Actual Configuration for Ci Build #
125 # ####################################################################################### #
127 def GetActiveScopes(self
):
128 ''' return tuple containing scopes that should be active for this process '''
129 scopes
= ("cibuild", "edk2-build", "host-based-test")
131 self
.ActualToolChainTag
= shell_environment
.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
133 if GetHostInfo().os
.upper() == "LINUX" and self
.ActualToolChainTag
.upper().startswith("GCC"):
134 if "AARCH64" in self
.ActualArchitectures
:
135 scopes
+= ("gcc_aarch64_linux",)
136 if "ARM" in self
.ActualArchitectures
:
137 scopes
+= ("gcc_arm_linux",)
138 if "RISCV64" in self
.ActualArchitectures
:
139 scopes
+= ("gcc_riscv64_unknown",)
143 def GetRequiredSubmodules(self
):
144 ''' return iterable containing RequiredSubmodule objects.
145 If no RequiredSubmodules return an empty iterable
148 rs
.append(RequiredSubmodule(
149 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
150 rs
.append(RequiredSubmodule(
151 "CryptoPkg/Library/OpensslLib/openssl", False))
152 rs
.append(RequiredSubmodule(
153 "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
154 rs
.append(RequiredSubmodule(
155 "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
156 rs
.append(RequiredSubmodule(
157 "MdeModulePkg/Library/BrotliCustomDecompressLib/brotli", False))
158 rs
.append(RequiredSubmodule(
159 "BaseTools/Source/C/BrotliCompress/brotli", False))
165 def GetDependencies(self
):
169 def GetPackagesPath(self
):
172 def GetWorkspaceRoot(self
):
173 ''' get WorkspacePath '''
174 return os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
176 def FilterPackagesToTest(self
, changedFilesList
: list, potentialPackagesList
: list) -> list:
177 ''' Filter potential packages to test based on changed files. '''
178 build_these_packages
= []
179 possible_packages
= potentialPackagesList
.copy()
180 for f
in changedFilesList
:
181 # split each part of path for comparison later
184 # python file change in .pytool folder causes building all
185 if f
.endswith(".py") and ".pytool" in nodes
:
186 build_these_packages
= possible_packages
189 # BaseTools files that might change the build
190 if "BaseTools" in nodes
:
191 if os
.path
.splitext(f
) not in [".txt", ".md"]:
192 build_these_packages
= possible_packages
194 return build_these_packages