Skip to content

Commit

Permalink
Docs: updated README.md on how to use custom mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
storypku committed Apr 6, 2022
1 parent b245e32 commit 2dd08f3
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,43 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_github_storypku_bazel_iwyu",
sha256 = "043b554c2cdaa7e7c56f2341452498a63f282baf9f086b08b29783c9b0fb6597",
strip_prefix = "bazel_iwyu-0.0.2",
strip_prefix = "bazel_iwyu-0.0.3",
sha256 = "TODO",
urls = [
"https://github.com/storypku/bazel_iwyu/archive/0.0.2.tar.gz",
"https://github.com/storypku/bazel_iwyu/archive/0.0.3.tar.gz",
],
)

load("@com_github_storypku_bazel_iwyu//bazel:dependencies.bzl", "bazel_iwyu_dependencies")
bazel_iwyu_dependencies()
```

3. Add the following to your bazelrc. (E.g., `.bazelrc`)
3. Add the following to your .bazelrc.

```
build:iwyu --aspects @com_github_storypku_bazel_iwyu//bazel/iwyu:iwyu.bzl%iwyu_aspect
build:iwyu --output_groups=report
```

If you would like to use your own IWYU mappings, put all your IMP files inside one directory, say,
`bazel/iwyu/mappings`, and create a filegroup target for it:

```python
# bazel/iwyu/BUILD.bazel
filegroup(
name = "my_mappings",
srcs = glob([
"mappings/*.imp",
]),
)
```

Then add the following to your `.bazelrc`,

```
build:iwyu --@com_github_storypku_bazel_iwyu//:iwyu_mappings=//bazel/iwyu:my_mappings
```

4. Run IWYU

```shell
Expand Down

0 comments on commit 2dd08f3

Please sign in to comment.