codeql/swift
Paolo Tranquilli 545c2f67e9
Merge pull request #11382 from github/alexdenisov/swift-relax-file-archiving
Swift: do not abort if cannot archive a source file
2022-11-23 06:56:26 +01:00
..
actions Swift: infrastructure for upgrade/downgrade scripts 2022-11-11 15:51:23 +01:00
codegen Swift: fix typo in docstring 2022-11-16 16:36:48 +01:00
downgrades Swift: add upgrade/downgrade scripts 2022-11-16 12:00:26 +01:00
extractor Merge pull request #11382 from github/alexdenisov/swift-relax-file-archiving 2022-11-23 06:56:26 +01:00
integration-tests Swift: autopep8 integration tests 2022-11-15 15:43:05 +01:00
ql Merge pull request #11292 from github/redsun82/swift-remove-ipa-from-dbscheme-cpp 2022-11-16 16:00:58 +00:00
third_party Swift: remove an `assert` from swift headers 2022-11-08 11:47:12 +01:00
tools Update qltest.sh 2022-11-04 13:04:24 +01:00
xcode-autobuilder Swift: make xcode-autobuilder tester work with several tests 2022-10-19 16:20:32 +02:00
.clang-format Swift: first skeleton extractor 2022-04-12 12:40:59 +02:00
.gitignore Swift: cmake generator for better IDE support 2022-10-13 15:25:24 +02:00
.pep8 Swift: implement python schema 2022-09-21 15:53:09 +02:00
.python-version Swift: bump actions/setup-python from 3 to 4 2022-10-19 18:10:42 +02:00
BUILD.bazel Swift: move libraries from `tools` to `third_party` 2022-10-26 07:05:56 +02:00
CMakeLists.txt Swift: fix cmake generator on Linux 2022-10-27 09:32:05 +02:00
README.md Swift: remove unneeded trailing `/` in `README.md` 2022-10-31 09:55:03 +01:00
codeql-extractor.yml Swift: first skeleton extractor 2022-04-12 12:40:59 +02:00
create_extractor_pack.py Swift: add `qltest.sh` tests 2022-10-21 12:54:09 +02:00
prefix.dbscheme Swift: implement python schema 2022-09-21 15:53:09 +02:00
rules.bzl Revert "Swift: print a helpful message on macOS ARM" 2022-09-14 10:34:46 +02:00
schema.py Swift: remove double newlines in schema 2022-11-15 15:00:30 +01:00

README.md

Swift on CodeQL

Warning

The Swift CodeQL package is an experimental and unsupported work in progress.

Building the Swift extractor

First ensure you have Bazel installed, for example with

brew install bazelisk

then from the ql directory run

bazel run //swift:create-extractor-pack    # --cpu=darwin_x86_64 # Uncomment on Arm-based Macs

which will install swift/extractor-pack.

Notice you can run bazel run :create-extractor-pack if you already are in the swift directory.

Using codeql ... --search-path=swift/extractor-pack will then pick up the Swift extractor. You can also use --search-path=., as the extractor pack is mentioned in the root codeql-workspace.yml. Alternatively, you can set up the search path in the per-user CodeQL configuration file .

Code generation

Run

bazel run //swift/codegen

to update generated files. This can be shortened to bazel run codegen if you are in the swift directory.

IDE setup

CLion and the native bazel plugin

You can use CLion with the official IntelliJ Bazel plugin, creating the project from scratch with default options. This is known to have issues on non-Linux platforms.

CMake project

The CMakeLists.txt file allows to load the Swift extractor as a CMake project, which allows integration into a wider variety of IDEs. Building with CMake also creates a compile_commands.json compilation database that can be picked up by even more IDEs. In particular, opening the swift directory in VSCode should work.

Debugging codeql database creation

If you want to debug a specific run of the extractor within an integration test or a complex codeql database create invocation, you can do so using gdbserver or lldb-server.

For example with gdbserver, you can

export CODEQL_EXTRACTOR_SWIFT_RUN_UNDER="gdbserver :1234"
export CODEQL_EXTRACTOR_SWIFT_RUN_UNDER_FILTER="SomeSwiftSource\.swift"  # can be any regex matching extractor args

before starting the database extraction, and when that source is encountered the extractor will be run under a gdbserver instance listening on port 1234. You can then attach to the running debugging server from gdb or your IDE. Please refer to your IDE's instructions for how to set up remote debugging.

In particular for breakpoints to work you might need to setup the following remote path mapping:

Remote Local
swift /absolute/path/to/codeql/swift
bazel-out /absolute/path/to/codeql/bazel-out