Commit Graph

36 Commits

Author SHA1 Message Date
Ivo List 653fb79676
Remove returning struct in cc_grpc_library (#32360)
Struct providers were deprecated
https://github.com/bazelbuild/bazel/issues/7347

release notes: no
2023-02-14 20:53:53 -08:00
Yash Tibrewal 41ec08c69a
Update third_party/protobuf to 3.21.4 (#30377)
* Update third_party/protobuf

* run tools/distrib/python/make_grpcio_tools.py

* regenerate protos for ruby, php

* update build_handwritten.yaml

* regenerate projects

* Build - Use :well_known_type_protos instead of :well_known_protos

* Fix target

* Update upb

* Update Python for Protobuf 4.21 (#140)

* Update protobuf dependency on grpcio-tools

* Off by one

* Drop python 3.6 support

* Try upgrading pip

* And in the other script

* Try to figure out if we're compatible with abi3

* See what we've already got installed

* Update the requirements.txt file I didn't know existed

* And here too

* See what's installed

* Let's try that again

* Remove

* Try to confirm version

* Let me see the generated code

* Fix non-Bazel test runner

* Work for all test directories

* Regenerate example protos

* Clean up

* Generate .pyi files

* Fix type checking and linting

* Exclude pyi files from isort

* Upgrade to 3.21.4

* Update iwyu to get around messy protobuf IWYU rules

Co-authored-by: Richard Belleville <gnossen@gmail.com>
2022-08-04 09:39:49 -07:00
Richard Belleville 468768865b
Make Buildifier Sanity Test Strict (#27807)
* Fix all lint errors in repo.

* Use strict buildifier by default

* Whoops. That file does not exist

* Attempt fix to buildifier invocation

* Add missing copyright
2021-11-03 14:57:04 -07:00
Alexander Grund c46dd9ca9d
Fix environment for protobuf compilation (#23664)
Add use_default_shell_env = True to protoc invocation to mirror
what the protobuf cc_proto_library & co are doing
Fixes a failure in invocing protoc when it is build in a non-default
environment (e.g. with a custom LD_LIBRARY_PATH)
2021-06-03 10:09:54 -07:00
Richard Belleville 05aa736840
Fix bazel copyright notices (#26353)
* Add copyright to Bazel files

* Add check for copyright in Bazel files

* Remove unintentional file
2021-05-25 12:15:30 -07:00
Yannic Bonenberger 06ecc87290 [bazel] Add fixes for --incompatible_load_proto_rules_from_bzl 2020-02-05 19:58:30 +01:00
Lidi Zheng c34bef4ca4 Format all Bazel files with buildifier 2019-11-05 14:03:52 -08:00
vam 461c053c37 [bazel][python] Support _virtual_imports input for py_proto_library and py_grpc_library rules
`proto_library` targets are used as deps for `py_proto_library` and `py_grpc_library` rules. The `proto_library` targets can be configured using `import_prefix` and/or `strip_import_prefix` (which essentially move original location of the proto file and, as result, affects import path within proto files themselves and in the generated language-specific stubs).

The biggest question to answer when generating stubs from moved protos is where to put result (this decision affects all downstream rules as well, because the location of file affects its import path).

This PR tries to follow same logic as the native `cc_proto_library` (created and maintained by Bazel team). For example, if we have `firestore.proto` file, which is located under `google/firestore/v1beta1` Bazel package and want to move it under `google/cloud/firestore_v1beta1/proto` (this is axactly what happens in googleapis repository), it can be configured the following way:

```bzl
proto_library(
    name = "firestore_moved_proto",
    srcs = ["firestore.proto"],
    import_prefix = "google/cloud/firestore_v1beta1/proto",
    strip_import_prefix = "google/firestore/v1beta1",
)
```

The rule above will first generate virtual `.proto` files (under new location) and only after that generate a binary descriptor from them.
Specifically it will generate the following "virtual" file under `_virtual_imports` subdirectory of same package:

```
bazel-bin/google/firestore/v1beta1/_virtual_imports/firestore_moved_proto/google/cloud/firestore_v1beta1/proto/common.proto
```

When supplied to `cc_proto_library`, like the following:

```bzl
cc_proto_library(
    name = "firestore_moved_cc_proto",
    deps = ["firestore_moved_proto"],
)
```

The rule will generate .cc and .h files like the following:
```
bazel-bin/google/firestore/v1beta1/_virtual_imports/firestore_moved_proto/google/cloud/firestore_v1beta1/proto/firestore.pb.h
bazel-bin/google/firestore/v1beta1/_virtual_imports/firestore_moved_proto/google/cloud/firestore_v1beta1/proto/firestore.pb.cc
```

Notice, that each generated `.cc` and `.h` file is prefixed with `_virtual_imports/<name_of_proto_library_target>`.

The python rules try to do same thing, so for the following py_proto_library rule:

```bzl
py_proto_library(
    name = "firestore_moved_py_proto",
    deps = [":firestore_moved_proto"],
)
```

It wil generate the following file:
```
bazel-bin/google/firestore/v1beta1/_virtual_imports/firestore_moved_proto/google/cloud/firestore_v1beta1/proto/firestore_pb2.py
```

I.e in same path as cc_proto_library.

This all woks, but an annoying part is that to use the generated library in some other py_library, in needs to specify the "_virtual_imports/proto_target" path as its "includes" parameter (and I can't make it better than that).

Another option would be to skeep the `_virtual_imports/<name_of_proto_library_target>` the suffix for the generated python stubs, which will make the path look like the following:
```
bazel-bin/google/firestore/v1beta1/google/cloud/firestore_v1beta1/proto/firestore_pb2.py
```

That will make using generated stubs simpler and cleaner (no need to specify imports argument), but it will make it inconsistent with the other rules (like cc_proto_library) and also more susseptible to naming conflicts (if there is already something under the generated path).
2019-09-02 18:00:40 -07:00
Marcel Hlopko ecf04ccf4d Require ProtoInfo in attributes, not "proto" 2019-06-20 18:57:33 +02:00
Marcel Hlopko 49f0fb9035 Migrate from dep.proto to dep[ProtoInfo] 2019-06-20 18:55:56 +02:00
Keith Smiley f131adf89c Fix bazel incompatible changes
When building grpc with the upcoming `--incompatible_depset_is_not_iterable` flag, these violations were found
2019-05-21 17:13:07 -07:00
vam 5c15471710 Fix generated files as input issue (generated files were supported neither as srcs nor as deps). 2019-05-07 14:55:10 -07:00
Richard Belleville 930cec4e27 Revert "Merge pull request #18912 from grpc/revert-bazel-changes"
This reverts commit c9a259aa3a, reversing
changes made to 9c882bc725.
2019-04-30 11:17:11 -07:00
Richard Belleville 50b5240d0a Revert "Merge pull request #18859 from grpc/internal_py_proto_library"
This reverts commit 5b720f19c1, reversing
changes made to a64ae3c0d5.
2019-04-29 17:47:56 -07:00
Richard Belleville f371d95c47 Handle protos at root package level 2019-04-26 17:03:16 -07:00
Richard Belleville 05f37c8143 Remove dependency on pubref/rules_proto.
This commit resolves #18331.
This commit resolves #18256.
This commit resolves... another TODO that apparently didn't have an
associated github issue.

We swap out pubref's implementation of py_proto_library with our own,
which more closely mirrors the interface of the internal
py_proto_library, taking the descriptor file output of a proto_library
rule as input.

One minor change in behavior was introduced for simplicity. When a
py_proto_library depends on a proto_library with a source proto file in
a subdirectory of the bazel package, the import module of the resultant
python library will reflect the package, *not* the full directory of the
proto file, including both the bazel package and the subdirectories, as
pubref did previously. This behavior also more closely mirrors google
internal behavior.

This commit also introduces a slightly more stringent bazel format
script. Buildifier on its own will not take care of long lines, but by
running yapf first, we end up with a more legible file. At the moment,
there is no sanity check associated with this formatter.
2019-04-24 17:36:08 -07:00
Laurent Le Brun 6f3a00c1a3 Fix for future Bazel changes
This fixes issues found by running Bazel with `--incompatible_no_support_tools_in_action_inputs` and `--incompatible_new_actions_api`.
2019-02-25 18:33:33 +01:00
Max Vorobev 25e13ac79b Fix incompatible_bzl_disallow_load_after_statement, deprecated attribute usage 2018-12-24 19:29:09 +03:00
Nicolas Noble 1995816b6b
Merge pull request #14625 from isturdy/generate-cc
Fix C++ codegen with bazel in subrepositories
2018-03-29 13:56:33 -07:00
yang-g 502ba74868 Rename generate_mock to generate_mocks 2018-03-21 16:43:02 -07:00
Ian Sturdy e6dfa9cd74 Fix cross-repository proto includes. 2018-03-19 16:12:45 -07:00
Ian Sturdy ec27b28121 Fix C++ codegen with bazel in subrepositories 2018-03-07 11:27:59 -08:00
Vladimir Moskva 759c7029b1 Rename set to depset 2017-09-14 15:40:27 +02:00
Craig Tiller a753371f05 Rework well_known_protos attr, and some other fixes 2017-05-16 13:09:33 -07:00
Makarand Dharmapurikar 2807951be5 Merge branch 'master' of https://github.com/grpc/grpc into fixbazel 2017-04-25 09:39:33 -07:00
MakMukhi c090c619c1 Merge pull request #10644 from MakMukhi/master
Added unit testing support.
2017-04-24 16:36:40 -07:00
Vijay Pai f74eaa6957 Fix up protobuf submodule name to match bazel expectation 2017-04-20 22:21:01 +00:00
Makarand Dharmapurikar c872a993e5 .proto and BUILD files can now in differnt dirs 2017-04-17 16:36:00 -07:00
Mahak Mukhi 78f12e5c76 Add _mock files to output list of generate_cc.bzl 2017-04-16 21:24:16 -07:00
Mahak Mukhi 459da91519 fixing bug 2017-04-16 20:51:30 -07:00
Mahak Mukhi a68829023c more sanity
trying to fix some sanity

nope that didn't work

fixing test failiures

added debug code

more trail and error

more trial and error

cleaning debug code
2017-04-15 19:09:45 -07:00
Mahak Mukhi 443a75dd22 1. Added golden file test.
2. Added support for mock.
3. Sanity fix.
2017-04-14 15:33:55 -07:00
Makarand Dharmapurikar e3e3b2aec8 changes for picking up well known protos
Add dependency and protoc argument for picking up well known protos
from the //third_party/protobuf repo
2017-03-07 16:12:56 -08:00
Nicolas "Pixel" Noble 24263c3f7a Fixing a few items with the new Bazel BUILD system:
-) Fixing Bazel 0.4.x breakage
-) Adding helloworld BUILD examples
-) Fixing grpc++ missing files.
-) Adding helloworld example as a test for Bazel basic.
2017-01-13 02:55:13 +01:00
Nicolas "Pixel" Noble 799bd5efb7 Adding shim for generating C++ protos. 2016-10-21 01:54:32 +02:00
Nicolas "Pixel" Noble 4dc64310bb Adding cc_grpc_library. 2016-10-20 23:07:37 +02:00