github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/docs/builtins.md (about)

     1  ---
     2  layout: default
     3  title: builtins
     4  permalink: examples/builtins
     5  parent: examples
     6  ---
     7  
     8  
     9  # builtins example
    10  
    11  `bazel test //example/golden:builtins_test`
    12  
    13  
    14  ## `BUILD.bazel` (after gazelle)
    15  
    16  ~~~python
    17  load("@rules_proto//proto:defs.bzl", "proto_library")
    18  load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile")
    19  
    20  # gazelle:proto_rule proto_compile implementation stackb:rules_proto:proto_compile
    21  # gazelle:proto_plugin cpp implementation builtin:cpp
    22  # gazelle:proto_plugin java implementation builtin:java
    23  # gazelle:proto_plugin closurejs implementation builtin:js:closure
    24  # gazelle:proto_plugin commonjs implementation builtin:js:common
    25  # gazelle:proto_plugin python implementation builtin:python
    26  # gazelle:proto_plugin ruby implementation builtin:ruby
    27  # gazelle:proto_plugin objc implementation builtin:objc
    28  # gazelle:proto_language builtins rule proto_compile
    29  # gazelle:proto_language builtins plugin cpp
    30  # gazelle:proto_language builtins plugin java
    31  # gazelle:proto_language builtins plugin closurejs
    32  # gazelle:proto_language builtins plugin commonjs
    33  # gazelle:proto_language builtins plugin python
    34  # gazelle:proto_language builtins plugin ruby
    35  # gazelle:proto_language builtins plugin objc
    36  
    37  proto_library(
    38      name = "test_proto",
    39      srcs = ["test.proto"],
    40      visibility = ["//visibility:public"],
    41  )
    42  
    43  proto_compile(
    44      name = "test_builtins_compile",
    45      outs = {"@build_stack_rules_proto//plugin/builtin:java": "test.srcjar"},
    46      options = {
    47          "@build_stack_rules_proto//plugin/builtin:closurejs": [
    48              "import_style=closure",
    49              "library=test_closure",
    50          ],
    51          "@build_stack_rules_proto//plugin/builtin:commonjs": ["import_style=commonjs"],
    52      },
    53      outputs = [
    54          "Test.pbobjc.h",
    55          "Test.pbobjc.m",
    56          "test.pb.cc",
    57          "test.pb.h",
    58          "test.srcjar",
    59          "test_closure.js",
    60          "test_pb.js",
    61          "test_pb.rb",
    62          "test_pb2.py",
    63      ],
    64      plugins = [
    65          "@build_stack_rules_proto//plugin/builtin:closurejs",
    66          "@build_stack_rules_proto//plugin/builtin:commonjs",
    67          "@build_stack_rules_proto//plugin/builtin:cpp",
    68          "@build_stack_rules_proto//plugin/builtin:java",
    69          "@build_stack_rules_proto//plugin/builtin:objc",
    70          "@build_stack_rules_proto//plugin/builtin:python",
    71          "@build_stack_rules_proto//plugin/builtin:ruby",
    72      ],
    73      proto = "test_proto",
    74  )
    75  ~~~
    76  
    77  
    78  ## `BUILD.bazel` (before gazelle)
    79  
    80  ~~~python
    81  # gazelle:proto_rule proto_compile implementation stackb:rules_proto:proto_compile
    82  # gazelle:proto_plugin cpp implementation builtin:cpp
    83  # gazelle:proto_plugin java implementation builtin:java
    84  # gazelle:proto_plugin closurejs implementation builtin:js:closure
    85  # gazelle:proto_plugin commonjs implementation builtin:js:common
    86  # gazelle:proto_plugin python implementation builtin:python
    87  # gazelle:proto_plugin ruby implementation builtin:ruby
    88  # gazelle:proto_plugin objc implementation builtin:objc
    89  # gazelle:proto_language builtins rule proto_compile
    90  # gazelle:proto_language builtins plugin cpp
    91  # gazelle:proto_language builtins plugin java
    92  # gazelle:proto_language builtins plugin closurejs
    93  # gazelle:proto_language builtins plugin commonjs
    94  # gazelle:proto_language builtins plugin python
    95  # gazelle:proto_language builtins plugin ruby
    96  # gazelle:proto_language builtins plugin objc
    97  ~~~
    98  
    99  
   100  ## `WORKSPACE`
   101  
   102  ~~~python
   103  local_repository(
   104      name = "build_stack_rules_proto",
   105      path = "../build_stack_rules_proto",
   106  )
   107  
   108  register_toolchains("@build_stack_rules_proto//toolchain:standard")
   109  
   110  # == Externals ==
   111  
   112  load("@build_stack_rules_proto//deps:core_deps.bzl", "core_deps")
   113  
   114  core_deps()
   115  
   116  # == Go ==
   117  
   118  load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
   119  
   120  go_rules_dependencies()
   121  
   122  go_register_toolchains(version = "1.18.2")
   123  
   124  # == Gazelle ==
   125  
   126  load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
   127  
   128  gazelle_dependencies()
   129  
   130  # == Protobuf ==
   131  
   132  load("@build_stack_rules_proto//deps:protobuf_core_deps.bzl", "protobuf_core_deps")
   133  
   134  protobuf_core_deps()
   135  ~~~
   136