A closer reading of the API for getsockopt revealed that we were
depending on an implementation detail of getsockopt on Linux. This
assumption breaks down on MacOS.
getsockopt merely guarantees that it will return on 0 in case of failure
and a value greater than 0 in case of success. There is no guarantee as
to *which* non-zero value you will receive. On Linux, it seems to be 1,
the value which was explicitly set. On MacOS, it seems to be the value
of the FLAG which was set, i.e. 512 for SO_REUSEPORT.
This commit ensures the check we use does not rely on either of these
implementation details.
This is needed to comply with bazel best practices (each proto file is first processed by proto_library: https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_library) and generally bring cc_grcp_library rule up to date with latest Bazel changes (the rule hasn't gotten much updates since 2016).
Detailed description.
Bazel has native `cc_proto_library` rule, but it does not have `cc_grpc_library`. The rule in cc_grpc_library in this repo seems like the best candidate.
This change makes possible using `cc_grpc_library` to generate on grpc library, and consume protobuf protion as dependencies. The typical `BUILD.bazel` file configuraiton now should look like the following:
```python
proto_library(
name = "my_proto",
srcs = ["my.proto"],
)
cc_proto_library(
name = "my_cc_proto",
deps = [":my_proto"]
)
cc_grpc_library(
name = "my_cc_grpc",
srcs = [":my_proto"],
deps = [":my_cc_proto"]
)
```
This allows to decouple all thre phases: proto descriptors generation (`proto_library`), protobuf messages library creation (`cc_proto_library`), grpc library creatio (`cc_grpc_library`).
Notice how `cc_grpc_library` depends on `proto_library` (as `src`) and on `cc_proto_library` (as `deps`). Currently cc_grpc_library is designed in a way that it encapsulates all of the above and directly accepts .proto files as srcs.
The previous version (before this PR) of cc_proto_library was encapsulating all of the 3 phases inside single `cc_proto_library` and also was doing it manually (without relying on the native `cc_proto_library`).
The `cc_proto_library` is kept backward-compatible with the old version.
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.