Skip to content

Commit 2976301

Browse files
makubackimergify[bot]
authored andcommitted
.pytool/CISettings.py: Integrate CodeQL
Adds the `--codeql` parameter to `stuart_update` and `stuart_ci_build`. - `stuart_update --codeql` - Downloads the CodeQL CLI locally. The command will pull the appropriate binary for the host OS. - `stuart_ci_build --codeql` - Runs CodeQL during the build resulting in a CodeQL database and SARIF result file in the `Build` directory. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sean Brogan <sean.brogan@microsoft.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
1 parent b531ca4 commit 2976301

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.pytool/CISettings.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,27 @@
77
##
88
import os
99
import logging
10+
import sys
1011
from edk2toolext.environment import shell_environment
1112
from edk2toolext.invocables.edk2_ci_build import CiBuildSettingsManager
1213
from edk2toolext.invocables.edk2_setup import SetupSettingsManager, RequiredSubmodule
1314
from edk2toolext.invocables.edk2_update import UpdateSettingsManager
1415
from edk2toolext.invocables.edk2_pr_eval import PrEvalSettingsManager
1516
from edk2toollib.utility_functions import GetHostInfo
17+
from pathlib import Path
18+
19+
20+
try:
21+
# Temporarily needed until edk2 can update to the latest edk2-pytools
22+
# that has the CodeQL helpers.
23+
#
24+
# May not be present until submodules are populated.
25+
#
26+
root = Path(__file__).parent.parent.resolve()
27+
sys.path.append(str(root/'BaseTools'/'Plugin'/'CodeQL'/'integration'))
28+
import stuart_codeql as codeql_helpers
29+
except ImportError:
30+
pass
1631

1732

1833
class Settings(CiBuildSettingsManager, UpdateSettingsManager, SetupSettingsManager, PrEvalSettingsManager):
@@ -34,13 +49,23 @@ def AddCommandLineOptions(self, parserObj):
3449
group.add_argument("-force_piptools", "--fpt", dest="force_piptools", action="store_true", default=False, help="Force the system to use pip tools")
3550
group.add_argument("-no_piptools", "--npt", dest="no_piptools", action="store_true", default=False, help="Force the system to not use pip tools")
3651

52+
try:
53+
codeql_helpers.add_command_line_option(parserObj)
54+
except NameError:
55+
pass
56+
3757
def RetrieveCommandLineOptions(self, args):
3858
super().RetrieveCommandLineOptions(args)
3959
if args.force_piptools:
4060
self.UseBuiltInBaseTools = True
4161
if args.no_piptools:
4262
self.UseBuiltInBaseTools = False
4363

64+
try:
65+
self.codeql = codeql_helpers.is_codeql_enabled_on_command_line(args)
66+
except NameError:
67+
pass
68+
4469
# ####################################################################################### #
4570
# Default Support for this Ci Build #
4671
# ####################################################################################### #
@@ -169,6 +194,11 @@ def GetActiveScopes(self):
169194
else:
170195
logging.warning("Falling back to using in-tree BaseTools")
171196

197+
try:
198+
scopes += codeql_helpers.get_scopes(self.codeql)
199+
except NameError:
200+
pass
201+
172202
self.ActualScopes = scopes
173203
return self.ActualScopes
174204

0 commit comments

Comments
 (0)