@@ -15,21 +15,29 @@ def get_workspace_packs(root):
1515
1616 return packs
1717
18+ def install_pack (pack_path , codeql_executable , mode ):
19+ # Run `codeql pack install` to install dependencies.
20+ command = [codeql_executable , 'pack' , 'install' , '--allow-prerelease' , '--mode' , mode , pack_path ]
21+ print (f'Running `{ " " .join (command )} `' )
22+ subprocess .check_call (command )
23+
1824parser = argparse .ArgumentParser (description = "Install CodeQL library pack dependencies." )
1925parser .add_argument ('--mode' , required = False , choices = ['use-lock' , 'update' , 'verify' , 'no-lock' ], default = "use-lock" , help = "Installation mode, identical to the `--mode` argument to `codeql pack install`" )
2026parser .add_argument ('--codeql' , required = False , default = 'codeql' , help = "Path to the `codeql` executable." )
27+ parser .add_argument ('--language' , required = False , help = "Which language (or 'common') to install pack dependencies for." )
2128args = parser .parse_args ()
2229
2330# Find the root of the repo
2431root = os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
2532
2633packs = get_workspace_packs (root )
2734
28- # Find the CodeQL packs in the repo. This can also return packs outside of the repo, if those packs
29- # are installed in a sibling directory to the CLI.
30- for pack in packs :
31- pack_path = os .path .join (root , pack )
32- # Run `codeql pack install` to install dependencies.
33- command = [args .codeql , 'pack' , 'install' , '--allow-prerelease' , '--mode' , args .mode , pack_path ]
34- print (f'Running `{ " " .join (command )} `' )
35- subprocess .check_call (command )
35+ # Always install the qtil source pack, which is used by all languages.
36+ install_pack (os .path .join (root , 'src' ), args .codeql , args .mode )
37+ if args .language == 'common' :
38+ # common means we want to run test/.
39+ install_pack (os .path .join (root , 'test' ), args .codeql , args .mode )
40+ else :
41+ # Otherwise, we need to install the language-specific src and test packs.
42+ install_pack (os .path .join (root , args .language , 'src' ), args .codeql , args .mode )
43+ install_pack (os .path .join (root , args .language , 'test' ), args .codeql , args .mode )
0 commit comments