|
3 | 3 | # Copyright (c) Microsoft Corporation. All rights reserved.
|
4 | 4 | # SPDX-License-Identifier: BSD-2-Clause-Patent
|
5 | 5 | ##
|
| 6 | +import glob |
6 | 7 | import os
|
7 | 8 | import logging
|
| 9 | +import sys |
8 | 10 | from edk2toolext.environment import shell_environment
|
9 | 11 | from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
|
10 | 12 | from edk2toolext.invocables.edk2_ci_setup import CiSetupSettingsManager
|
11 | 13 | from edk2toolext.invocables.edk2_setup import SetupSettingsManager
|
12 | 14 | from edk2toolext.invocables.edk2_update import UpdateSettingsManager
|
13 | 15 | from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
|
14 | 16 | from edk2toollib.utility_functions import GetHostInfo
|
| 17 | +from pathlib import Path |
| 18 | + |
| 19 | +try: |
| 20 | + # May not be present until submodules are populated |
| 21 | + root = Path(__file__).parent.parent.resolve() |
| 22 | + sys.path.append(str(root / 'MU_BASECORE' / '.pytool' / 'Plugin' / 'CodeQL' / 'integration')) |
| 23 | + import stuart_codeql as codeql_helpers |
| 24 | +except ImportError: |
| 25 | + pass |
15 | 26 |
|
16 | 27 |
|
17 | 28 | class Settings(
|
@@ -52,13 +63,23 @@ def AddCommandLineOptions(self, parserObj):
|
52 | 63 | help="Force the system to not use pip tools",
|
53 | 64 | )
|
54 | 65 |
|
| 66 | + try: |
| 67 | + codeql_helpers.add_command_line_option(parserObj) |
| 68 | + except NameError: |
| 69 | + pass |
| 70 | + |
55 | 71 | def RetrieveCommandLineOptions(self, args):
|
56 | 72 | super().RetrieveCommandLineOptions(args)
|
57 | 73 | if args.force_piptools:
|
58 | 74 | self.UseBuiltInBaseTools = True
|
59 | 75 | if args.no_piptools:
|
60 | 76 | self.UseBuiltInBaseTools = False
|
61 | 77 |
|
| 78 | + try: |
| 79 | + self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args) |
| 80 | + except NameError: |
| 81 | + pass |
| 82 | + |
62 | 83 | # ####################################################################################### #
|
63 | 84 | # Default Support for this Ci Build #
|
64 | 85 | # ####################################################################################### #
|
@@ -169,7 +190,28 @@ def GetActiveScopes(self):
|
169 | 190 | scopes += ("gcc_arm_linux",)
|
170 | 191 | if "RISCV64" in self.ActualArchitectures:
|
171 | 192 | scopes += ("gcc_riscv64_unknown",)
|
| 193 | + |
| 194 | + try: |
| 195 | + scopes += codeql_helpers.get_scopes(self.codeql) |
| 196 | + |
| 197 | + if self.codeql: |
| 198 | + shell_environment.GetBuildVars().SetValue( |
| 199 | + "STUART_CODEQL_AUDIT_ONLY", |
| 200 | + "TRUE", |
| 201 | + "Set in CISettings.py") |
| 202 | + codeql_filter_files = [str(n) for n in glob.glob( |
| 203 | + os.path.join(self.GetWorkspaceRoot(), |
| 204 | + '**/CodeQlFilters.yml'), |
| 205 | + recursive=True)] |
| 206 | + shell_environment.GetBuildVars().SetValue( |
| 207 | + "STUART_CODEQL_FILTER_FILES", |
| 208 | + ','.join(codeql_filter_files), |
| 209 | + "Set in CISettings.py") |
| 210 | + except NameError: |
| 211 | + pass |
| 212 | + |
172 | 213 | self.ActualScopes = scopes
|
| 214 | + |
173 | 215 | return self.ActualScopes
|
174 | 216 |
|
175 | 217 | def GetRequiredSubmodules(self):
|
|
0 commit comments