]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - .pytool/CISettings.py
MdePkg/IndustryStandard: Fix various typos
[mirror_edk2.git] / .pytool / CISettings.py
... / ...
CommitLineData
1# @file\r
2#\r
3# Copyright (c) Microsoft Corporation.\r
4# SPDX-License-Identifier: BSD-2-Clause-Patent\r
5##\r
6import os\r
7import logging\r
8from edk2toolext.environment import shell_environment\r
9from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager\r
10from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubmodule\r
11from edk2toolext.invocables.edk2_update import UpdateSettingsManager\r
12from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager\r
13from edk2toollib.utility_functions import GetHostInfo\r
14\r
15\r
16class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):\r
17\r
18 def __init__(self):\r
19 self.ActualPackages = []\r
20 self.ActualTargets = []\r
21 self.ActualArchitectures = []\r
22 self.ActualToolChainTag = ""\r
23\r
24 # ####################################################################################### #\r
25 # Extra CmdLine configuration #\r
26 # ####################################################################################### #\r
27\r
28 def AddCommandLineOptions(self, parserObj):\r
29 pass\r
30\r
31 def RetrieveCommandLineOptions(self, args):\r
32 pass\r
33\r
34 # ####################################################################################### #\r
35 # Default Support for this Ci Build #\r
36 # ####################################################################################### #\r
37\r
38 def GetPackagesSupported(self):\r
39 ''' return iterable of edk2 packages supported by this build.\r
40 These should be edk2 workspace relative paths '''\r
41\r
42 return ("MdePkg",\r
43 "MdeModulePkg",\r
44 "NetworkPkg",\r
45 "PcAtChipsetPkg",\r
46 "SecurityPkg",\r
47 "UefiCpuPkg",\r
48 "FmpDevicePkg",\r
49 "ShellPkg",\r
50 "FatPkg",\r
51 "CryptoPkg",\r
52 "UnitTestFrameworkPkg"\r
53 )\r
54\r
55 def GetArchitecturesSupported(self):\r
56 ''' return iterable of edk2 architectures supported by this build '''\r
57 return ("IA32",\r
58 "X64",\r
59 "ARM",\r
60 "AARCH64")\r
61\r
62 def GetTargetsSupported(self):\r
63 ''' return iterable of edk2 target tags supported by this build '''\r
64 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")\r
65\r
66 # ####################################################################################### #\r
67 # Verify and Save requested Ci Build Config #\r
68 # ####################################################################################### #\r
69\r
70 def SetPackages(self, list_of_requested_packages):\r
71 ''' Confirm the requested package list is valid and configure SettingsManager\r
72 to build the requested packages.\r
73\r
74 Raise UnsupportedException if a requested_package is not supported\r
75 '''\r
76 unsupported = set(list_of_requested_packages) - \\r
77 set(self.GetPackagesSupported())\r
78 if(len(unsupported) > 0):\r
79 logging.critical(\r
80 "Unsupported Package Requested: " + " ".join(unsupported))\r
81 raise Exception("Unsupported Package Requested: " +\r
82 " ".join(unsupported))\r
83 self.ActualPackages = list_of_requested_packages\r
84\r
85 def SetArchitectures(self, list_of_requested_architectures):\r
86 ''' Confirm the requests architecture list is valid and configure SettingsManager\r
87 to run only the requested architectures.\r
88\r
89 Raise Exception if a list_of_requested_architectures is not supported\r
90 '''\r
91 unsupported = set(list_of_requested_architectures) - \\r
92 set(self.GetArchitecturesSupported())\r
93 if(len(unsupported) > 0):\r
94 logging.critical(\r
95 "Unsupported Architecture Requested: " + " ".join(unsupported))\r
96 raise Exception(\r
97 "Unsupported Architecture Requested: " + " ".join(unsupported))\r
98 self.ActualArchitectures = list_of_requested_architectures\r
99\r
100 def SetTargets(self, list_of_requested_target):\r
101 ''' Confirm the request target list is valid and configure SettingsManager\r
102 to run only the requested targets.\r
103\r
104 Raise UnsupportedException if a requested_target is not supported\r
105 '''\r
106 unsupported = set(list_of_requested_target) - \\r
107 set(self.GetTargetsSupported())\r
108 if(len(unsupported) > 0):\r
109 logging.critical(\r
110 "Unsupported Targets Requested: " + " ".join(unsupported))\r
111 raise Exception("Unsupported Targets Requested: " +\r
112 " ".join(unsupported))\r
113 self.ActualTargets = list_of_requested_target\r
114\r
115 # ####################################################################################### #\r
116 # Actual Configuration for Ci Build #\r
117 # ####################################################################################### #\r
118\r
119 def GetActiveScopes(self):\r
120 ''' return tuple containing scopes that should be active for this process '''\r
121 scopes = ("cibuild", "edk2-build", "host-based-test")\r
122\r
123 self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")\r
124\r
125 if GetHostInfo().os.upper() == "WINDOWS":\r
126 scopes += ('host-test-win',)\r
127\r
128 if GetHostInfo().os.upper() == "LINUX" and self.ActualToolChainTag.upper().startswith("GCC"):\r
129 if "AARCH64" in self.ActualArchitectures:\r
130 scopes += ("gcc_aarch64_linux",)\r
131 if "ARM" in self.ActualArchitectures:\r
132 scopes += ("gcc_arm_linux",)\r
133\r
134 return scopes\r
135\r
136 def GetRequiredSubmodules(self):\r
137 ''' return iterable containing RequiredSubmodule objects.\r
138 If no RequiredSubmodules return an empty iterable\r
139 '''\r
140 rs = []\r
141 rs.append(RequiredSubmodule(\r
142 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))\r
143 rs.append(RequiredSubmodule(\r
144 "CryptoPkg/Library/OpensslLib/openssl", False))\r
145 rs.append(RequiredSubmodule(\r
146 "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))\r
147 return rs\r
148\r
149 def GetName(self):\r
150 return "Edk2"\r
151\r
152 def GetDependencies(self):\r
153 return [\r
154 ]\r
155\r
156 def GetPackagesPath(self):\r
157 return ()\r
158\r
159 def GetWorkspaceRoot(self):\r
160 ''' get WorkspacePath '''\r
161 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\r
162\r
163 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:\r
164 ''' Filter potential packages to test based on changed files. '''\r
165 build_these_packages = []\r
166 possible_packages = potentialPackagesList.copy()\r
167 for f in changedFilesList:\r
168 # split each part of path for comparison later\r
169 nodes = f.split("/")\r
170\r
171 # python file change in .pytool folder causes building all\r
172 if f.endswith(".py") and ".pytool" in nodes:\r
173 build_these_packages = possible_packages\r
174 break\r
175\r
176 # BaseTools files that might change the build\r
177 if "BaseTools" in nodes:\r
178 if os.path.splitext(f) not in [".txt", ".md"]:\r
179 build_these_packages = possible_packages\r
180 break\r
181 return build_these_packages\r