Skip to content

Commit

Permalink
In direct compilation mode, setup protoc actions directly
Browse files Browse the repository at this point in the history
This allows adding support for 'options' attr :)
  • Loading branch information
aaliddell committed Feb 14, 2021
1 parent 10f877e commit 683bdd5
Show file tree
Hide file tree
Showing 63 changed files with 511 additions and 155 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,7 @@ _rule = rule(
def example_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)

```
Expand Down
8 changes: 6 additions & 2 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ android_proto_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -104,6 +105,7 @@ android_grpc_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -172,8 +174,9 @@ android_proto_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `exports` | `list` | false | `[]` | List of labels to pass as exports attr to underlying lang_library rule |

---
Expand Down Expand Up @@ -234,6 +237,7 @@ android_grpc_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `exports` | `list` | false | `[]` | List of labels to pass as exports attr to underlying lang_library rule |
12 changes: 10 additions & 2 deletions android/android_grpc_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ _rule = rule(
aspects = [android_grpc_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//android:javalite_plugin"),
Label("//android:grpc_javalite_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def android_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = False,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
11 changes: 9 additions & 2 deletions android/android_proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ _rule = rule(
aspects = [android_proto_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//android:javalite_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def android_proto_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = False,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
4 changes: 3 additions & 1 deletion closure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ closure_proto_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -101,5 +102,6 @@ closure_proto_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
11 changes: 9 additions & 2 deletions closure/closure_proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ _rule = rule(
aspects = [closure_proto_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//closure:js_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def closure_proto_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
8 changes: 6 additions & 2 deletions cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ cpp_proto_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -90,6 +91,7 @@ cpp_grpc_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -134,8 +136,9 @@ cpp_proto_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |

---

Expand Down Expand Up @@ -177,5 +180,6 @@ cpp_grpc_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
12 changes: 10 additions & 2 deletions cpp/cpp_grpc_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ _rule = rule(
aspects = [cpp_grpc_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//cpp:cpp_plugin"),
Label("//cpp:grpc_cpp_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def cpp_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
11 changes: 9 additions & 2 deletions cpp/cpp_proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ _rule = rule(
aspects = [cpp_proto_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//cpp:cpp_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def cpp_proto_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
8 changes: 6 additions & 2 deletions csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ csharp_proto_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -131,6 +132,7 @@ csharp_grpc_compile(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |

---
Expand Down Expand Up @@ -196,8 +198,9 @@ csharp_proto_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |

---

Expand Down Expand Up @@ -259,5 +262,6 @@ csharp_grpc_library(
| Name | Type | Mandatory | Default | Description |
| ---: | :--- | --------- | ------- | ----------- |
| `protos` | `list<ProtoInfo>` | true | `[]` | List of labels that provide a `ProtoInfo` (such as `rules_proto` `proto_library`) |
| `options` | `dict<string, list(string)>` | false | `[]` | Extra options to pass to plugins, as a dict of plugin label -> list of strings. The key * can be used exclusively to apply to all plugins |
| `verbose` | `int` | false | `0` | The verbosity level. Supported values and results are 1: *show command*, 2: *show command and sandbox after running protoc*, 3: *show command and sandbox before and after running protoc*, 4. *show env, command, expected outputs and sandbox before and after running protoc* |
| `deps` | `list` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
| `deps` | `list<Label/string>` | false | `[]` | List of labels to pass as deps attr to underlying lang_library rule |
12 changes: 10 additions & 2 deletions csharp/csharp_grpc_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ _rule = rule(
aspects = [csharp_grpc_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//csharp:csharp_plugin"),
Label("//csharp:grpc_csharp_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def csharp_grpc_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
11 changes: 9 additions & 2 deletions csharp/csharp_proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ _rule = rule(
aspects = [csharp_proto_compile_aspect],
doc = "DEPRECATED: Use protos attr",
),
_plugins = attr.label_list(
doc = "List of protoc plugins to apply",
providers = [ProtoPluginInfo],
default = [
Label("//csharp:csharp_plugin"),
],
),
),
toolchains = [str(Label("//protobuf:toolchain_type"))],
)

# Create macro for converting attrs and passing to compile
def csharp_proto_compile(**kwargs):
_rule(
verbose_string = "{}".format(kwargs.get("verbose", 0)),
merge_directories = True,
**{k: v for k, v in kwargs.items() if k != "merge_directories"}
**kwargs
)
Loading

0 comments on commit 683bdd5

Please sign in to comment.