Skip to content

Commit

Permalink
rename proto rule while maintaining backwards compat (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
andyscott authored and johnynek committed Aug 19, 2019
1 parent 247fce9 commit 93433cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions docs/scalapb_proto_library.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# scalapb_proto_library
# scala_proto_library

To use this rule, you'll first need to add the following to your `WORKSPACE` file,
which adds a few dependencies needed for ScalaPB:
Expand All @@ -8,17 +8,17 @@ load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_reposito
scala_proto_repositories(scala_version = "2.12.8") # or whatever scala_version you're on
```

Then you can import `scalapb_proto_library` in any `BUILD` file like this:
Then you can import `scala_proto_library` in any `BUILD` file like this:

```python
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scalapb_proto_library")
scalapb_proto_library(
load("@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_library")
scala_proto_library(
name = "my_scala_proto_lib",
deps = [":my_target"],
)
```

`scalapb_proto_library` generates a Scala library of Scala proto bindings
`scala_proto_library` generates a Scala library of Scala proto bindings
generated by the [ScalaPB compiler](https://github.com/scalapb/ScalaPB).

## Attributes
Expand Down Expand Up @@ -65,4 +65,4 @@ toolchain(
| extra_generator_dependencies | `List of labels, optional` <br>
| grpc_deps | `List of labels, optional (has default)` <br> gRPC dependencies. A sensible default is provided.
| implicit_compile_deps | `List of labels, optional (has default)` <br> ScalaPB dependencies. A sensible default is provided.
| scalac | `Label, optional (has default)` <br> Target for scalac. A sensible default is provided.
| scalac | `Label, optional (has default)` <br> Target for scalac. A sensible default is provided.
10 changes: 7 additions & 3 deletions scala_proto/scala_proto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def scala_proto_repositories(



def _scalapb_proto_library_impl(ctx):
def _scala_proto_library_impl(ctx):
aspect_info = merge_scalapb_aspect_info(
[dep[ScalaPBAspectInfo] for dep in ctx.attr.deps],
)
Expand All @@ -50,10 +50,14 @@ def _scalapb_proto_library_impl(ctx):
DefaultInfo(files = aspect_info.output_files),
]

scalapb_proto_library = rule(
implementation = _scalapb_proto_library_impl,
scala_proto_library = rule(
implementation = _scala_proto_library_impl,
attrs = {
"deps": attr.label_list(aspects = [scalapb_aspect]),
},
provides = [DefaultInfo, ScalaPBInfo, JavaInfo],
)


def scalapb_proto_library(**kwargs):
scala_proto_library(**kwargs)

0 comments on commit 93433cf

Please sign in to comment.