Merge pull request #12164 from github/redsun82/swift-codegen-outside-bazel

Swift: make `codegen` run also outside `bazel`
This commit is contained in:
Paolo Tranquilli
2023-02-13 10:32:20 +01:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -19,6 +19,13 @@ separated list to select what to generate (choosing among `dbscheme`, `ql`, `tra
C++ code is generated during build (see [`swift/extractor/trap/BUILD.bazel`](../extractor/trap/BUILD.bazel)). After a
build you can browse the generated code in `bazel-bin/swift/extractor/trap/generated`.
For debugging you can also run `./codegen.py` directly. You must then ensure dependencies are installed, which you can
with the command
```bash
pip3 install -r ./requirements.txt
```
## Implementation notes
The suite uses [mustache templating](https://mustache.github.io/) for generation. Templates are

View File

@@ -3,12 +3,16 @@
import argparse
import logging
import pathlib
import os
import sys
import importlib
import types
import pathlib
import typing
if 'BUILD_WORKSPACE_DIRECTORY' not in os.environ:
# we are not running with `bazel run`, set up module search path
_repo_root = pathlib.Path(__file__).resolve().parents[2]
sys.path.append(str(_repo_root))
from swift.codegen.lib import render, paths
from swift.codegen.generators import generate