2019-10-08 05:25:30 +02:00
|
|
|
# @file
|
|
|
|
#
|
|
|
|
# Copyright (c) Microsoft Corporation.
|
2020-04-03 07:51:12 +02:00
|
|
|
# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
2020-12-03 11:27:51 +01:00
|
|
|
# Copyright (c) 2020 - 2021, ARM Limited. All rights reserved.<BR>
|
2019-10-08 05:25:30 +02:00
|
|
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
##
|
|
|
|
import os
|
|
|
|
import logging
|
2023-09-26 00:12:31 +02:00
|
|
|
import sys
|
2019-10-08 05:25:30 +02:00
|
|
|
from edk2toolext.environment import shell_environment
|
|
|
|
from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
|
|
|
|
from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubmodule
|
|
|
|
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
|
|
|
|
from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
|
|
|
|
from edk2toollib.utility_functions import GetHostInfo
|
2023-09-26 00:12:31 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
# Temporarily needed until edk2 can update to the latest edk2-pytools
|
|
|
|
# that has the CodeQL helpers.
|
|
|
|
#
|
|
|
|
# May not be present until submodules are populated.
|
|
|
|
#
|
|
|
|
root = Path(__file__).parent.parent.resolve()
|
|
|
|
sys.path.append(str(root/'BaseTools'/'Plugin'/'CodeQL'/'integration'))
|
|
|
|
import stuart_codeql as codeql_helpers
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.ActualPackages = []
|
|
|
|
self.ActualTargets = []
|
|
|
|
self.ActualArchitectures = []
|
|
|
|
self.ActualToolChainTag = ""
|
2021-02-09 01:50:33 +01:00
|
|
|
self.UseBuiltInBaseTools = None
|
|
|
|
self.ActualScopes = None
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
# ####################################################################################### #
|
|
|
|
# Extra CmdLine configuration #
|
|
|
|
# ####################################################################################### #
|
|
|
|
|
|
|
|
def AddCommandLineOptions(self, parserObj):
|
2021-02-09 01:50:33 +01:00
|
|
|
group = parserObj.add_mutually_exclusive_group()
|
|
|
|
group.add_argument("-force_piptools", "--fpt", dest="force_piptools", action="store_true", default=False, help="Force the system to use pip tools")
|
|
|
|
group.add_argument("-no_piptools", "--npt", dest="no_piptools", action="store_true", default=False, help="Force the system to not use pip tools")
|
2019-10-08 05:25:30 +02:00
|
|
|
|
2023-09-26 00:12:31 +02:00
|
|
|
try:
|
|
|
|
codeql_helpers.add_command_line_option(parserObj)
|
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
|
2019-10-08 05:25:30 +02:00
|
|
|
def RetrieveCommandLineOptions(self, args):
|
2021-02-09 01:50:33 +01:00
|
|
|
super().RetrieveCommandLineOptions(args)
|
|
|
|
if args.force_piptools:
|
|
|
|
self.UseBuiltInBaseTools = True
|
|
|
|
if args.no_piptools:
|
|
|
|
self.UseBuiltInBaseTools = False
|
2019-10-08 05:25:30 +02:00
|
|
|
|
2023-09-26 00:12:31 +02:00
|
|
|
try:
|
|
|
|
self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args)
|
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
|
2019-10-08 05:25:30 +02:00
|
|
|
# ####################################################################################### #
|
|
|
|
# Default Support for this Ci Build #
|
|
|
|
# ####################################################################################### #
|
|
|
|
|
|
|
|
def GetPackagesSupported(self):
|
|
|
|
''' return iterable of edk2 packages supported by this build.
|
|
|
|
These should be edk2 workspace relative paths '''
|
|
|
|
|
2021-04-21 12:04:11 +02:00
|
|
|
return ("ArmPkg",
|
2021-04-21 12:05:34 +02:00
|
|
|
"ArmPlatformPkg",
|
2021-04-21 12:04:11 +02:00
|
|
|
"ArmVirtPkg",
|
2020-08-07 19:29:34 +02:00
|
|
|
"DynamicTablesPkg",
|
2022-09-03 02:56:28 +02:00
|
|
|
"EmbeddedPkg",
|
2020-04-08 08:09:02 +02:00
|
|
|
"EmulatorPkg",
|
2022-09-06 21:46:08 +02:00
|
|
|
"IntelFsp2Pkg",
|
2022-09-06 23:18:28 +02:00
|
|
|
"IntelFsp2WrapperPkg",
|
2020-04-08 08:09:02 +02:00
|
|
|
"MdePkg",
|
2019-10-08 05:25:30 +02:00
|
|
|
"MdeModulePkg",
|
|
|
|
"NetworkPkg",
|
|
|
|
"PcAtChipsetPkg",
|
|
|
|
"SecurityPkg",
|
|
|
|
"UefiCpuPkg",
|
|
|
|
"FmpDevicePkg",
|
|
|
|
"ShellPkg",
|
2022-09-01 20:51:45 +02:00
|
|
|
"SignedCapsulePkg",
|
2020-12-03 11:27:51 +01:00
|
|
|
"StandaloneMmPkg",
|
2019-10-08 05:25:30 +02:00
|
|
|
"FatPkg",
|
2020-01-22 19:17:23 +01:00
|
|
|
"CryptoPkg",
|
2022-01-18 22:54:51 +01:00
|
|
|
"PrmPkg",
|
2020-04-08 08:09:02 +02:00
|
|
|
"UnitTestFrameworkPkg",
|
2020-10-06 03:12:59 +02:00
|
|
|
"OvmfPkg",
|
2021-08-20 08:43:37 +02:00
|
|
|
"RedfishPkg",
|
2022-10-04 17:01:50 +02:00
|
|
|
"SourceLevelDebugPkg",
|
2021-08-20 08:43:37 +02:00
|
|
|
"UefiPayloadPkg"
|
2019-10-08 05:25:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def GetArchitecturesSupported(self):
|
|
|
|
''' return iterable of edk2 architectures supported by this build '''
|
2020-04-03 07:51:12 +02:00
|
|
|
return (
|
|
|
|
"IA32",
|
2019-10-08 05:25:30 +02:00
|
|
|
"X64",
|
|
|
|
"ARM",
|
2020-04-03 07:51:12 +02:00
|
|
|
"AARCH64",
|
2021-11-15 10:59:53 +01:00
|
|
|
"RISCV64",
|
|
|
|
"LOONGARCH64")
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
def GetTargetsSupported(self):
|
|
|
|
''' return iterable of edk2 target tags supported by this build '''
|
|
|
|
return ("DEBUG", "RELEASE", "NO-TARGET", "NOOPT")
|
|
|
|
|
|
|
|
# ####################################################################################### #
|
|
|
|
# Verify and Save requested Ci Build Config #
|
|
|
|
# ####################################################################################### #
|
|
|
|
|
|
|
|
def SetPackages(self, list_of_requested_packages):
|
|
|
|
''' Confirm the requested package list is valid and configure SettingsManager
|
|
|
|
to build the requested packages.
|
|
|
|
|
|
|
|
Raise UnsupportedException if a requested_package is not supported
|
|
|
|
'''
|
|
|
|
unsupported = set(list_of_requested_packages) - \
|
|
|
|
set(self.GetPackagesSupported())
|
|
|
|
if(len(unsupported) > 0):
|
|
|
|
logging.critical(
|
|
|
|
"Unsupported Package Requested: " + " ".join(unsupported))
|
|
|
|
raise Exception("Unsupported Package Requested: " +
|
|
|
|
" ".join(unsupported))
|
|
|
|
self.ActualPackages = list_of_requested_packages
|
|
|
|
|
|
|
|
def SetArchitectures(self, list_of_requested_architectures):
|
|
|
|
''' Confirm the requests architecture list is valid and configure SettingsManager
|
|
|
|
to run only the requested architectures.
|
|
|
|
|
|
|
|
Raise Exception if a list_of_requested_architectures is not supported
|
|
|
|
'''
|
|
|
|
unsupported = set(list_of_requested_architectures) - \
|
|
|
|
set(self.GetArchitecturesSupported())
|
|
|
|
if(len(unsupported) > 0):
|
|
|
|
logging.critical(
|
|
|
|
"Unsupported Architecture Requested: " + " ".join(unsupported))
|
|
|
|
raise Exception(
|
|
|
|
"Unsupported Architecture Requested: " + " ".join(unsupported))
|
|
|
|
self.ActualArchitectures = list_of_requested_architectures
|
|
|
|
|
|
|
|
def SetTargets(self, list_of_requested_target):
|
|
|
|
''' Confirm the request target list is valid and configure SettingsManager
|
|
|
|
to run only the requested targets.
|
|
|
|
|
|
|
|
Raise UnsupportedException if a requested_target is not supported
|
|
|
|
'''
|
|
|
|
unsupported = set(list_of_requested_target) - \
|
|
|
|
set(self.GetTargetsSupported())
|
|
|
|
if(len(unsupported) > 0):
|
|
|
|
logging.critical(
|
|
|
|
"Unsupported Targets Requested: " + " ".join(unsupported))
|
|
|
|
raise Exception("Unsupported Targets Requested: " +
|
|
|
|
" ".join(unsupported))
|
|
|
|
self.ActualTargets = list_of_requested_target
|
|
|
|
|
|
|
|
# ####################################################################################### #
|
|
|
|
# Actual Configuration for Ci Build #
|
|
|
|
# ####################################################################################### #
|
|
|
|
|
|
|
|
def GetActiveScopes(self):
|
|
|
|
''' return tuple containing scopes that should be active for this process '''
|
2021-02-09 01:50:33 +01:00
|
|
|
if self.ActualScopes is None:
|
|
|
|
scopes = ("cibuild", "edk2-build", "host-based-test")
|
|
|
|
|
|
|
|
self.ActualToolChainTag = shell_environment.GetBuildVars().GetValue("TOOL_CHAIN_TAG", "")
|
|
|
|
|
|
|
|
is_linux = GetHostInfo().os.upper() == "LINUX"
|
|
|
|
|
|
|
|
if self.UseBuiltInBaseTools is None:
|
|
|
|
is_linux = GetHostInfo().os.upper() == "LINUX"
|
|
|
|
# try and import the pip module for basetools
|
|
|
|
try:
|
|
|
|
import edk2basetools
|
|
|
|
self.UseBuiltInBaseTools = True
|
|
|
|
except ImportError:
|
|
|
|
self.UseBuiltInBaseTools = False
|
|
|
|
pass
|
|
|
|
|
|
|
|
if self.UseBuiltInBaseTools == True:
|
|
|
|
scopes += ('pipbuild-unix',) if is_linux else ('pipbuild-win',)
|
|
|
|
logging.warning("Using Pip Tools based BaseTools")
|
|
|
|
else:
|
|
|
|
logging.warning("Falling back to using in-tree BaseTools")
|
|
|
|
|
2023-09-26 00:12:31 +02:00
|
|
|
try:
|
|
|
|
scopes += codeql_helpers.get_scopes(self.codeql)
|
2023-10-14 03:56:53 +02:00
|
|
|
|
|
|
|
if self.codeql:
|
|
|
|
shell_environment.GetBuildVars().SetValue(
|
|
|
|
"STUART_CODEQL_AUDIT_ONLY",
|
|
|
|
"TRUE",
|
|
|
|
"Set in CISettings.py")
|
2023-09-26 00:12:31 +02:00
|
|
|
except NameError:
|
|
|
|
pass
|
|
|
|
|
2021-02-09 01:50:33 +01:00
|
|
|
self.ActualScopes = scopes
|
|
|
|
return self.ActualScopes
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
def GetRequiredSubmodules(self):
|
|
|
|
''' return iterable containing RequiredSubmodule objects.
|
|
|
|
If no RequiredSubmodules return an empty iterable
|
|
|
|
'''
|
2020-01-22 19:17:23 +01:00
|
|
|
rs = []
|
2019-10-08 05:25:30 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3", False))
|
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"CryptoPkg/Library/OpensslLib/openssl", False))
|
2020-01-22 19:17:23 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
|
2022-06-28 19:33:02 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"UnitTestFrameworkPkg/Library/GoogleTestLib/googletest", False))
|
2019-12-27 07:28:20 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
|
2020-02-12 11:08:15 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"MdeModulePkg/Library/BrotliCustomDecompressLib/brotli", False))
|
2020-02-21 03:21:06 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"BaseTools/Source/C/BrotliCompress/brotli", False))
|
2020-12-02 07:15:01 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"RedfishPkg/Library/JsonLib/jansson", False))
|
2023-03-24 01:06:33 +01:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"UnitTestFrameworkPkg/Library/SubhookLib/subhook", False))
|
2023-05-05 01:48:12 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"MdePkg/Library/BaseFdtLib/libfdt", False))
|
2023-05-10 22:54:05 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"MdePkg/Library/MipiSysTLib/mipisyst", False))
|
2023-08-21 04:25:43 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"CryptoPkg/Library/MbedTlsLib/mbedtls", False))
|
2024-04-18 11:28:16 +02:00
|
|
|
rs.append(RequiredSubmodule(
|
|
|
|
"SecurityPkg/DeviceSecurity/SpdmLib/libspdm", False))
|
2019-10-08 05:25:30 +02:00
|
|
|
return rs
|
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return "Edk2"
|
|
|
|
|
|
|
|
def GetDependencies(self):
|
2020-01-22 19:17:23 +01:00
|
|
|
return [
|
|
|
|
]
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
def GetPackagesPath(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def GetWorkspaceRoot(self):
|
|
|
|
''' get WorkspacePath '''
|
|
|
|
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
|
|
|
def FilterPackagesToTest(self, changedFilesList: list, potentialPackagesList: list) -> list:
|
|
|
|
''' Filter potential packages to test based on changed files. '''
|
2020-01-22 19:17:23 +01:00
|
|
|
build_these_packages = []
|
|
|
|
possible_packages = potentialPackagesList.copy()
|
2019-10-08 05:25:30 +02:00
|
|
|
for f in changedFilesList:
|
2020-01-22 19:17:23 +01:00
|
|
|
# split each part of path for comparison later
|
|
|
|
nodes = f.split("/")
|
2019-10-08 05:25:30 +02:00
|
|
|
|
|
|
|
# python file change in .pytool folder causes building all
|
|
|
|
if f.endswith(".py") and ".pytool" in nodes:
|
|
|
|
build_these_packages = possible_packages
|
|
|
|
break
|
|
|
|
|
|
|
|
# BaseTools files that might change the build
|
|
|
|
if "BaseTools" in nodes:
|
|
|
|
if os.path.splitext(f) not in [".txt", ".md"]:
|
|
|
|
build_these_packages = possible_packages
|
|
|
|
break
|
|
|
|
return build_these_packages
|