Skip to content

Commit c4adafe

Browse files
committed
Add docstring explaining how packs are added to a bundle
1 parent 0dc6814 commit c4adafe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

codeql_bundle/helpers/bundle.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,23 @@ def getCodeQLPacks(self) -> List[ResolvedCodeQLPack]:
185185
return self.workspace_packs
186186

187187
def add_packs(self, *packs: ResolvedCodeQLPack):
188+
"""
189+
Add packs and their workspace dependencies to the bundle. Standard library packs are customized if needed and standard query packs are recreated.
190+
191+
The approach taken is to first create a dependency graph from the provided packs and their dependencies.
192+
During the dependency graph construction we track which standard library packs are customized by customization packs and add those and
193+
the standard query packs depending on the customized standard library packs to the graph.
194+
195+
Once the dependency graph is constructed we use the graph to determine the order in which to process the packs.
196+
For each pack kind we process the pack as necessary.
197+
Library packs are bundled, query packs are (re)created, and customization packs are bundle and added as a dependency to the standard library pack they customize.
198+
Last but not least, the `Customizations.qll` module is updated to import the customization packs whenever we re-bundle a standard library pack.
199+
200+
During the process a few hacks are applied. The customization packs that are bundled have their dependencies removed to prevent circular dependencies between the
201+
customization packs and the standard library pack they customize.
202+
Languages that do not have a `Customizations.qll` module are provided with one. This process will add the `Customizations.qll` module to the standard library pack
203+
and import as the first module in the language module (eg., `cpp.qll` will import `Customizations.qll` as the first module).
204+
"""
188205
# Keep a map of standard library packs to their customization packs so we know which need to be modified.
189206
std_lib_deps : dict[ResolvedCodeQLPack, List[ResolvedCodeQLPack]] = defaultdict(list)
190207
pack_sorter : TopologicalSorter[ResolvedCodeQLPack] = TopologicalSorter()

0 commit comments

Comments
 (0)