Skip to content

Commit 81240ca

Browse files
committed
Add create database method
1 parent c5ea428 commit 81240ca

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/shared/codeql.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,18 @@ def format(self, path: Path) -> None:
139139
if not result.returncode == 0:
140140
raise CodeQLError(
141141
f"Failed to format file {path}", stdout=result.stdout, stderr=result.stderr, returncode=result.returncode)
142+
143+
def create_database(self, src_root: Path, language: str, database: Path, *build_commands : str, **options: str) -> None:
144+
command = ['codeql', 'database', 'create']
145+
options['source-root'] = str(src_root)
146+
options['language'] = language
147+
148+
command_options = self.__build_command_options(**options)
149+
command.extend(command_options)
150+
command.extend([f'--command={build_command}' for build_command in build_commands])
151+
command.append(str(database))
152+
153+
result = subprocess.run(command, capture_output=True)
154+
if not result.returncode == 0:
155+
raise CodeQLError(
156+
f"Failed to build database {database} from {src_root} with language {language} and commands [{','.join(build_commands)}]", stdout=result.stdout, stderr=result.stderr, returncode=result.returncode)

0 commit comments

Comments
 (0)