]> git.proxmox.com Git - mirror_edk2.git/blame - .pytool/CISettings.py
MdeModulePkg/Smbios: Add TCG PFP rev 105 support.
[mirror_edk2.git] / .pytool / CISettings.py
CommitLineData
4eb2baba
SB
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 )\r
53\r
54 def GetArchitecturesSupported(self):\r
55 ''' return iterable of edk2 architectures supported by this build '''\r
56 return ("IA32",\r
57 "X64",\r
58 "ARM",\r
59 "AARCH64")\r
60\r
61 def GetTargetsSupported(self):\r
62 ''' return iterable of edk2 target tags supported by this build '''\r
63 return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")\r
64\r
65 # ####################################################################################### #\r
66 # Verify and Save requested Ci Build Config #\r
67 # ####################################################################################### #\r
68\r
69 def SetPackages(self, list_of_requested_packages):\r
70 ''' Confirm the requested package list is valid and configure SettingsManager\r
71 to build the requested packages.\r
72\r
73 Raise UnsupportedException if a requested_package is not supported\r
74 '''\r
75 unsupported = set(list_of_requested_packages) - \\r
76 set(self.GetPackagesSupported())\r
77 if(len(unsupported) > 0):\r
78 logging.critical(\r
79 "Unsupported Package Requested: " + " ".join(unsupported))\r
80 raise Exception("Unsupported Package Requested: " +\r
81 " ".join(unsupported))\r
82 self.ActualPackages = list_of_requested_packages\r
83\r
84 def SetArchitectures(self, list_of_requested_architectures):\r
85 ''' Confirm the requests architecture list is valid and configure SettingsManager\r
86 to run only the requested architectures.\r
87\r
88 Raise Exception if a list_of_requested_architectures is not supported\r
89 '''\r
90 unsupported = set(list_of_requested_architectures) - \\r
91 set(self.GetArchitecturesSupported())\r
92 if(len(unsupported) > 0):\r
93 logging.critical(\r
94 "Unsupported Architecture Requested: " + " ".join(unsupported))\r
95 raise Exception(\r
96 "Unsupported Architecture Requested: " + " ".join(unsupported))\r
97 self.ActualArchitectures = list_of_requested_architectures\r
98\r
99 def SetTargets(self, list_of_requested_target):\r
100 ''' Confirm the request target list is valid and configure SettingsManager\r
101 to run only the requested targets.\r
102\r
103 Raise UnsupportedException if a requested_target is not supported\r
104 '''\r
105 unsupported = set(list_of_requested_target) - \\r
106 set(self.GetTargetsSupported())\r
107 if(len(unsupported) > 0):\r
108 logging.critical(\r
109 "Unsupported Targets Requested: " + " ".join(unsupported))\r
110 raise Exception("Unsupported Targets Requested: " +\r
111 " ".join(unsupported))\r
112 self.ActualTargets = list_of_requested_target\r
113\r
114 # ####################################################################################### #\r
115 # Actual Configuration for Ci Build #\r
116 # ####################################################################################### #\r
117\r
118 def GetActiveScopes(self):\r
119 ''' return tuple containing scopes that should be active for this process '''\r
120 scopes = ("cibuild","edk2-build")\r
121\r
122 self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")\r
123\r
124 if GetHostInfo().os.upper() == "LINUX" and self.ActualToolChainTag.upper().startswith("GCC"):\r
125 if "AARCH64" in self.ActualArchitectures:\r
126 scopes += ("gcc_aarch64_linux",)\r
127 if "ARM" in self.ActualArchitectures:\r
128 scopes += ("gcc_arm_linux",)\r
129\r
130 return scopes\r
131\r
132 def GetRequiredSubmodules(self):\r
133 ''' return iterable containing RequiredSubmodule objects.\r
134 If no RequiredSubmodules return an empty iterable\r
135 '''\r
136 rs=[]\r
137 rs.append(RequiredSubmodule(\r
138 "ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))\r
139 rs.append(RequiredSubmodule(\r
140 "CryptoPkg/Library/OpensslLib/openssl", False))\r
141 return rs\r
142\r
143 def GetName(self):\r
144 return "Edk2"\r
145\r
146 def GetDependencies(self):\r
147 return []\r
148\r
149 def GetPackagesPath(self):\r
150 return ()\r
151\r
152 def GetWorkspaceRoot(self):\r
153 ''' get WorkspacePath '''\r
154 return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\r
155\r
156 def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:\r
157 ''' Filter potential packages to test based on changed files. '''\r
158 build_these_packages=[]\r
159 possible_packages=potentialPackagesList.copy()\r
160 for f in changedFilesList:\r
161 nodes=f.split("/") # split each part of path for comparison later\r
162\r
163 # python file change in .pytool folder causes building all\r
164 if f.endswith(".py") and ".pytool" in nodes:\r
165 build_these_packages = possible_packages\r
166 break\r
167\r
168 # BaseTools files that might change the build\r
169 if "BaseTools" in nodes:\r
170 if os.path.splitext(f) not in [".txt", ".md"]:\r
171 build_these_packages = possible_packages\r
172 break\r
173 return build_these_packages\r