Skip to content

Commit 3a53f8f

Browse files
ssaradssaradpkeith
authored
[bazel] Update Bazel README with Bzlmod & WORKSPACE examples (#2918)
Co-authored-by: Sarad <[email protected]> Co-authored-by: Keith Smiley <[email protected]>
1 parent 0530f3e commit 3a53f8f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,25 @@ Start contributing to SwiftSyntax see [this guide](CONTRIBUTING.md) for more inf
3636
## Bazel
3737

3838
SwiftSyntax provides an experimental [Bazel](https://bazel.build) build configuration, maintained by Keith Smiley.
39-
To use it you can pull the source archive from the relevant release tag
40-
into your `WORKSPACE` and depend on the libraries you need from the
39+
To use it, you can pull the source archive from the relevant release tag
40+
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)
41+
42+
```python3
43+
bazel_dep(name = "swift-syntax", version = "600.0.1")
44+
```
45+
46+
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
47+
48+
```python3
49+
http_archive(
50+
name = "SwiftSyntax",
51+
sha256 = "f070fd44db9b33f430fd5b5d2700f1e2001c0028711859600e80cc975074fab0",
52+
strip_prefix = "swift-syntax-509.1.0",
53+
url = "https://github.com/apple/swift-syntax/archive/refs/tags/509.1.0.tar.gz",
54+
)
55+
```
56+
57+
and depend on the libraries you need from the
4158
[`BUILD.bazel`](BUILD.bazel) file. Each library also has an associated
4259
`Library_opt` target (such as `SwiftSyntax_opt`) which forces
4360
SwiftSyntax to always build with optimizations enabled. This may help

0 commit comments

Comments
 (0)