CISettings.py 8.1 KB

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