Skip to content

Commit 1218145

Browse files
committed
Codegen: update README.md files
1 parent 06a6450 commit 1218145

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

misc/codegen/README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
# Code generation suite
22

33
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:
55

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))
98
* C++ tags and trap entries (see [`trapgen.py`](generators/trapgen.py))
109
* C++ structured classes (see [`cppgen.py`](generators/cppgen.py))
1110

11+
An example `schema.py` [can be found in the Swift package](../../swift/schema.py).
12+
1213
## Usage
1314

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+
1620
See `bazel run //misc/codegen -- --help` for a list of all options. In particular `--generate` can be used with a comma
1721
separated list to select what to generate (choosing among `dbscheme`, `ql`, `trap` and `cpp`).
1822

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-
2923
## Implementation notes
3024

3125
The suite uses [mustache templating](https://mustache.github.io/) for generation. Templates are

swift/codegen/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This package aliases [`misc/codegen`](../misc/codegen) providing the Swift-specific options
2+
in [`swift/codegen.conf`](../codegen.conf).
3+
4+
Running `bazel run //swift/codegen` will generate all checked in
5+
files ([dbscheme](../ql/lib/swift.dbscheme), [QL generated code](../ql/lib/codeql/swift/generated),
6+
[generated QL stubs](../ql/lib/codeql/swift/elements), [generated QL tests](../ql/test/extractor-tests/generated)).
7+
8+
C++ code is generated during build (see [`swift/extractor/trap/BUILD.bazel`](../extractor/trap/BUILD.bazel)). After a
9+
build you can browse the generated code in `bazel-bin/swift/extractor/trap/generated` from the root of the `codeql`
10+
repository.

0 commit comments

Comments
 (0)