diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index ccc30413cb..b68cfac90c 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -7,6 +7,7 @@ ## import os import logging +import sys from edk2toolext.environment import shell_environment from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager # MU_CHANGE @@ -14,6 +15,15 @@ from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubm from edk2toolext.invocables.edk2_update import UpdateSettingsManager from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager from edk2toollib.utility_functions import GetHostInfo +from pathlib import Path + +try: + # May not be present until submodules are populated + root = Path(__file__).parent.parent.resolve() + sys.path.append(str(root/'MU_BASECORE'/'.pytool'/'Plugin'/'CodeQL'/'integration')) + import stuart_codeql as codeql_helpers +except ImportError: + pass # MU_CHANGE - Add CiSetupSettingsManager superclass. @@ -36,6 +46,11 @@ class Settings(CiSetupSettingsManager, CiBuildSettingsManager, UpdateSettingsMan 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") + try: + codeql_helpers.add_command_line_option(parserObj) + except NameError: + pass + def RetrieveCommandLineOptions(self, args): super().RetrieveCommandLineOptions(args) if args.force_piptools: @@ -43,6 +58,11 @@ class Settings(CiSetupSettingsManager, CiBuildSettingsManager, UpdateSettingsMan if args.no_piptools: self.UseBuiltInBaseTools = False + try: + self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args) + except NameError: + pass + # ####################################################################################### # # Default Support for this Ci Build # # ####################################################################################### # @@ -153,6 +173,18 @@ class Settings(CiSetupSettingsManager, CiBuildSettingsManager, UpdateSettingsMan scopes += ("gcc_arm_linux",) if "RISCV64" in self.ActualArchitectures: scopes += ("gcc_riscv64_unknown",) + + try: + scopes += codeql_helpers.get_scopes(self.codeql) + + if self.codeql: + shell_environment.GetBuildVars().SetValue( + "STUART_CODEQL_AUDIT_ONLY", + "TRUE", + "Set in CISettings.py") + except NameError: + pass + self.ActualScopes = scopes return self.ActualScopes