|
1 | 1 | # Code generation suite
|
2 | 2 |
|
3 | 3 | This directory contains the code generation suite used by the Swift extractor and the QL library. This suite will use
|
4 |
| -the abstract class specification of [`schema.yml`](schema.yml) to generate: |
| 4 | +the abstract class specification of `schema.py` to generate: |
5 | 5 |
|
6 |
| -* [the `dbscheme` file](../ql/lib/misc.dbscheme) (see [`dbschemegen.py`](generators/dbschemegen.py)) |
7 |
| -* [the QL generated code](../ql/lib/codeql/swift/generated) and when |
8 |
| - appropriate [the corresponding stubs](../ql/lib/codeql/swift/elements) (see [`qlgen.py`](generators/qlgen.py)) |
| 6 | +* the `dbscheme` file (see [`dbschemegen.py`](generators/dbschemegen.py)) |
| 7 | +* the QL generated code and when appropriate the corresponding stubs (see [`qlgen.py`](generators/qlgen.py)) |
9 | 8 | * C++ tags and trap entries (see [`trapgen.py`](generators/trapgen.py))
|
10 | 9 | * C++ structured classes (see [`cppgen.py`](generators/cppgen.py))
|
11 | 10 |
|
| 11 | +An example `schema.py` [can be found in the Swift package](../../swift/schema.py). |
| 12 | + |
12 | 13 | ## Usage
|
13 | 14 |
|
14 |
| -By default `bazel run //misc/codegen` will update all checked-in generated files (`dbscheme` and QL sources). You can |
15 |
| -append `--` followed by other options to tweak the behaviour, which is mainly intended for debugging. |
| 15 | +By default `bazel run //misc/codegen -- -c your-codegen.conf` will load options from `your-codegen.conf`. See |
| 16 | +the [Swift configuration](../../swift/codegen.conf) for an example. Calling `misc/codegen/codegen.py` directly (provided |
| 17 | +you installed dependencies via `pip3 install -r misc/codegen/requirements.txt`) will use a file named `codegen.conf` |
| 18 | +contained in an ancestor directory if any exists. |
| 19 | + |
16 | 20 | See `bazel run //misc/codegen -- --help` for a list of all options. In particular `--generate` can be used with a comma
|
17 | 21 | separated list to select what to generate (choosing among `dbscheme`, `ql`, `trap` and `cpp`).
|
18 | 22 |
|
19 |
| -C++ code is generated during build (see [`swift/extractor/trap/BUILD.bazel`](../extractor/trap/BUILD.bazel)). After a |
20 |
| -build you can browse the generated code in `bazel-bin/swift/extractor/trap/generated`. |
21 |
| - |
22 |
| -For debugging you can also run `./codegen.py` directly. You must then ensure dependencies are installed, which you can |
23 |
| -with the command |
24 |
| - |
25 |
| -```bash |
26 |
| -pip3 install -r ./requirements.txt |
27 |
| -``` |
28 |
| - |
29 | 23 | ## Implementation notes
|
30 | 24 |
|
31 | 25 | The suite uses [mustache templating](https://mustache.github.io/) for generation. Templates are
|
|
0 commit comments