Swift: DX changes based on my new setup experience

This commit is contained in:
Nora Dimitrijević
2022-10-10 14:05:51 +02:00
parent 8664017fe4
commit ea3510e766
2 changed files with 12 additions and 7 deletions

View File

@@ -1,8 +1,10 @@
# Swift on CodeQL
## Warning
The Swift codeql package is an experimental and unsupported work in progress.
The Swift CodeQL package is an experimental and unsupported work in progress.
## Usage
## Building the Swift extractor
First ensure you have Bazel installed, for example with
@@ -13,16 +15,17 @@ brew install bazelisk
then from the `ql` directory run
```bash
bazel run //swift:create-extractor-pack
bazel run //swift:create-extractor-pack # --cpu=darwin_x86_64 # Uncomment on Arm-based Macs
```
which will install `swift/extractor-pack`.
Using `--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`.
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](https://codeql.github.com/docs/codeql-cli/specifying-command-options-in-a-codeql-configuration-file/#using-a-codeql-configuration-file).
## Code generation
Run

View File

@@ -10,5 +10,7 @@ for src in *.swift; do
opts=(-sdk "$CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk" -c -primary-file $src)
opts+=($(sed -n '1 s=//codeql-extractor-options:==p' $src))
echo -e "calling extractor with flags: ${opts[@]}\n" >> $QLTEST_LOG
"$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor" "${opts[@]}" >> $QLTEST_LOG 2>&1
"$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor" "${opts[@]}" >> $QLTEST_LOG 2>&1 || FAILED=1
done
[ -z "$FAILED" ] || cat "$QLTEST_LOG" # Show compiler errors on extraction failure