Skip to content

Commit

Permalink
[bazel] Update Bazel README with Bzlmod & WORKSPACE examples (#2918)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarad <[email protected]>
Co-authored-by: Keith Smiley <[email protected]>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent 0530f3e commit 3a53f8f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,25 @@ Start contributing to SwiftSyntax see [this guide](CONTRIBUTING.md) for more inf
## Bazel

SwiftSyntax provides an experimental [Bazel](https://bazel.build) build configuration, maintained by Keith Smiley.
To use it you can pull the source archive from the relevant release tag
into your `WORKSPACE` and depend on the libraries you need from the
To use it, you can pull the source archive from the relevant release tag
into your `MODULE.bazel` file (preferred and recommended) with `bazel_dep`. Bzlmod support was added starting release of `509.0.0` and above. All available versions can be found in the [Bazel Central Registry](https://registry.bazel.build/modules/swift-syntax)

```python3
bazel_dep(name = "swift-syntax", version = "600.0.1")
```

You can also pull source archive with `WORKSPACE` but note that it is preferred to use `MODULE.bazel`. To use `WORKSPACE` and swift-syntax, you can use `http_archive` as such

```python3
http_archive(
name = "SwiftSyntax",
sha256 = "f070fd44db9b33f430fd5b5d2700f1e2001c0028711859600e80cc975074fab0",
strip_prefix = "swift-syntax-509.1.0",
url = "https://github.com/apple/swift-syntax/archive/refs/tags/509.1.0.tar.gz",
)
```

and depend on the libraries you need from the
[`BUILD.bazel`](BUILD.bazel) file. Each library also has an associated
`Library_opt` target (such as `SwiftSyntax_opt`) which forces
SwiftSyntax to always build with optimizations enabled. This may help
Expand Down

0 comments on commit 3a53f8f

Please sign in to comment.