From ce95fd011415a4fcca9403c0a5d791b05e0cc6c4 Mon Sep 17 00:00:00 2001 From: Brendan Bates Date: Mon, 16 Mar 2026 15:48:38 +1100 Subject: [PATCH 1/3] Passthrough the RAM command line arg to the pack bundle and create commands --- codeql_bundle/cli.py | 8 ++++++++ codeql_bundle/helpers/bundle.py | 9 +++++++++ codeql_bundle/helpers/codeql.py | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/codeql_bundle/cli.py b/codeql_bundle/cli.py index b1f254c..23d093b 100644 --- a/codeql_bundle/cli.py +++ b/codeql_bundle/cli.py @@ -72,6 +72,12 @@ type=click.Path(exists=True, path_type=Path), help="Path to a JSON file specifying additional data to install into the bundle", ) +@click.option( + "-M", + "--ram", + type=click.Int, + help="Set total amount of RAM that the compiler should be allowed to use.", +) @click.argument("packs", nargs=-1, required=True) def main( bundle_path: Path, @@ -82,6 +88,7 @@ def main( platform: List[str], code_scanning_config: Optional[Path], additional_data_config: Optional[Path], + ram: Optional[int], packs: List[str], ) -> None: @@ -109,6 +116,7 @@ def main( bundle = CustomBundle(bundle_path, workspace) # options for custom bundle bundle.disable_precompilation = no_precompile + bundle.ram = ram unsupported_platforms = list( filter( diff --git a/codeql_bundle/helpers/bundle.py b/codeql_bundle/helpers/bundle.py index 9278586..6d29dc3 100644 --- a/codeql_bundle/helpers/bundle.py +++ b/codeql_bundle/helpers/bundle.py @@ -278,6 +278,15 @@ def disable_precompilation(self): def disable_precompilation(self, value: bool): self._disable_precompilation = value + @property + def ram(self): + return self.codeql.ram + + @ram.setter + def ram(self, value: int): + self.codeql.ram = value + + class CustomBundle(Bundle): def __init__(self, bundle_path: Path, workspace_path: Path = Path.cwd()) -> None: diff --git a/codeql_bundle/helpers/codeql.py b/codeql_bundle/helpers/codeql.py index f5a9462..bd1e1bf 100644 --- a/codeql_bundle/helpers/codeql.py +++ b/codeql_bundle/helpers/codeql.py @@ -64,6 +64,7 @@ class CodeQL: def __init__(self, codeql_path: Path): self.codeql_path = codeql_path self._version = None + self._ram = None @property def disable_precompilation(self): @@ -73,6 +74,14 @@ def disable_precompilation(self): def disable_precompilation(self, value: bool): self._disable_precompilation = value + @property + def ram(self): + return self._ram + + @ram.setter + def ram(self, value: int): + self._ram = value + def _exec(self, command: str, *args: str) -> subprocess.CompletedProcess[str]: logger.debug( f"Running CodeQL command: {command} with arguments: {' '.join(args)}" @@ -84,7 +93,7 @@ def _exec(self, command: str, *args: str) -> subprocess.CompletedProcess[str]: ) def version(self) -> Version: - if self._version != None: + if self._version is not None: return self._version else: cp = self._exec("version", "--format=json") @@ -146,6 +155,10 @@ def pack_bundle( if len(additional_packs) > 0: args.append(f"--additional-packs={':'.join(map(str,additional_packs))}") + + if self.ram is not None: + args.append(f"--ram={self.ram}") + cp = self._exec( "pack", *args, @@ -177,6 +190,8 @@ def pack_create( args.append("--qlx") if len(additional_packs) > 0: args.append(f"--additional-packs={':'.join(map(str,additional_packs))}") + if self.ram is not None: + args.append(f"--ram={self.ram}") cp = self._exec( "pack", *args, From c3946679eb7233e2aaa99e8efeeb8052f43faf0c Mon Sep 17 00:00:00 2001 From: Brendan Bates Date: Mon, 15 Jun 2026 13:11:09 +1000 Subject: [PATCH 2/3] Log when RAM amount is changed from the default, fix CLI param type def --- codeql_bundle/cli.py | 2 +- codeql_bundle/helpers/codeql.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codeql_bundle/cli.py b/codeql_bundle/cli.py index 23d093b..28b0405 100644 --- a/codeql_bundle/cli.py +++ b/codeql_bundle/cli.py @@ -75,7 +75,7 @@ @click.option( "-M", "--ram", - type=click.Int, + type=click.INT, help="Set total amount of RAM that the compiler should be allowed to use.", ) @click.argument("packs", nargs=-1, required=True) diff --git a/codeql_bundle/helpers/codeql.py b/codeql_bundle/helpers/codeql.py index bd1e1bf..ae6aacd 100644 --- a/codeql_bundle/helpers/codeql.py +++ b/codeql_bundle/helpers/codeql.py @@ -157,6 +157,7 @@ def pack_bundle( args.append(f"--additional-packs={':'.join(map(str,additional_packs))}") if self.ram is not None: + logging.info(f"Using {self.ram} MB of RAM for packing {pack.config.name}.") args.append(f"--ram={self.ram}") cp = self._exec( @@ -191,6 +192,7 @@ def pack_create( if len(additional_packs) > 0: args.append(f"--additional-packs={':'.join(map(str,additional_packs))}") if self.ram is not None: + logging.info(f"Using {self.ram} MB of RAM for packing {pack.config.name}.") args.append(f"--ram={self.ram}") cp = self._exec( "pack", From 3c08e09ca8cbcd0a7b49adc055cef1a314bf415c Mon Sep 17 00:00:00 2001 From: Brendan Bates Date: Thu, 18 Jun 2026 11:57:28 +1000 Subject: [PATCH 3/3] Use all available threads when bundling libraries, differentiate log message for when changing ram usage for pack bundling vs pack creating --- codeql_bundle/helpers/codeql.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codeql_bundle/helpers/codeql.py b/codeql_bundle/helpers/codeql.py index ae6aacd..608f175 100644 --- a/codeql_bundle/helpers/codeql.py +++ b/codeql_bundle/helpers/codeql.py @@ -146,7 +146,7 @@ def pack_bundle( if not pack.config.library: raise CodeQLException(f"Cannot bundle non-library pack {pack.config.name}!") - args = ["bundle", "--format=json", f"--pack-path={output_path}"] + args = ["bundle", "--format=json", f"--pack-path={output_path}", "--threads=0"] if disable_precompilation: args.append("--no-precompile") logging.warn( @@ -157,7 +157,7 @@ def pack_bundle( args.append(f"--additional-packs={':'.join(map(str,additional_packs))}") if self.ram is not None: - logging.info(f"Using {self.ram} MB of RAM for packing {pack.config.name}.") + logging.info(f"Using {self.ram} MB of RAM for bundling {pack.config.name}.") args.append(f"--ram={self.ram}") cp = self._exec(