Commit Graph

36 Commits

Author SHA1 Message Date
Larry Safran 9bf04db0d3
reorder bazel rule parameters to satisfy CheckBzlFormat (#11118) 2024-04-22 16:14:47 -07:00
hvadehra add8c37a41
Add `load()` statements for the Bazel builtin top-level java symbols (#11105)
Loads are being added in preparation for moving the symbols out of Bazel and into `rules_java`.
2024-04-17 16:43:21 -07:00
Eric Anderson 65a6b3bc21 java_grpc_library.bzl: Support runfiles for protoc and the plugin
To support runfiles, the rule has to track more than just the
executable. `files_to_run` has both the runfile and executable
information (as separate fields), as does `files`, (combined as depset).
So using those when able is inherently "safe." `files_to_run.executable`
is only the executable, so does not propagate dependency information,
so we make sure to pass `files` to the rule in addition.
(`files_to_run.executable` is formatted into a string, so it wouldn't
carry depset information anyway.)

As originally noticed in cl/597962426
2024-01-19 17:02:55 -08:00
Eric Anderson cb03bd2346 java_grpc_library.bzl: Support Auto Exec Groups
Tested with --incompatible_auto_exec_groups=true with Bazel 7
2024-01-10 13:46:20 -08:00
kotlaja 9ab35b05de
java_grpc_library.bzl: Disable Automatic Exec Groups inside grpc libraries (#10514) 2023-09-05 17:21:10 -07:00
Eric Anderson 778c209751 java_grpc_library.bzl: Allow toolchain to use annotation processors
While not easy to use because java_grpc_library() uses a fixed
toolchain, it is possible for downstream users to apply a patch to the
repo to add their own annotation processors. This feature was added
inside Google so exporting it reduces the diff between internal and
external and causes no harm.

cl/280287611
2023-08-14 12:51:18 -07:00
kotlaja e6d9b41895
bazel: Add java toolchain type to all rules which are using java_common (#10225) 2023-05-30 11:48:43 -07:00
Greg e325dc9112
Replace ctx.host_configuration.host_path_separator with ctx.configuration.host_path_separator. (#9742)
Replace ctx.host_configuration.host_path_separator with ctx.configuration.host_path_separator.

This is because

1. we're removing ctx.host_configuration
2. host_path_separator's value doesn't depend on the configuration (the API is misleading by embedding it under ctx.configuration). So this is a no-op.

Internal ref cl/494008561.
2022-12-14 12:13:31 -08:00
Sergii Tkachenko 80cd7ec457
bazel: Migrate from `cfg = "host"` to `cfg = "exec"` (#9695)
This change migrates from `cfg = "host"` to `cfg = "exec"`.
This is a no-op cleanup: `cfg = "host"` is a deprecated alias
for `cfg = "exec"`.

Tested:

```
bazel build //grpclb:grpclb
bazel build //compiler:java_grpc_library_toolchain
bazel build //compiler:grpc_java_plugin
bazel build '//compiler:*'
```

Internal ref cl/487924699
2022-11-16 13:01:59 -08:00
Jesse Schalken 1a6840accd
Pass use_default_shell_env = True for protoc (#8984)
If protoc is compiled with MinGW it will depend on libstdc++-6.dll which is found in C:\msys64\mingw64\bin and can only be found by inheriting PATH from the environment.
2022-03-16 13:38:37 -07:00
Ivo List bb51bb6dfa
java_grpc_library.bzl: Fix parameters of java_common.compile (#7598)
Parameter host_javabase is removed.

This is preparation for flipping incompatible_java_common_parameters in
Bazel 5. See https://github.com/bazelbuild/bazel/issues/12373

Bazel versions prior to 4 require host_javabase, so are no longer supported.
2021-10-08 13:48:22 -07:00
Liam Miller-Cushon 084f5bc4bd java_grpc_library: Inline find_java_toolchain and find_java_runtime_toolchain
These methods were used to migrate the Java toolchains to use toolchain
resolution. Now that the migration is complete, the toolchain providers
can be used directly.
2020-01-30 12:55:40 -08:00
Jannis Andrija Schnitzer 93898734c2 bazel: Fix java path separator bug on Windows (#6054) 2019-08-14 14:28:31 -07:00
Ran f261af3445
java_grpc_library.bzl: Migrate from 'proto' to ProtoInfo syntax (#5994)
* Migrate the provider containing information about protocol buffers from the old-style 'dep.proto' pattern to the new-style 'dep[ProtoInfo]' one.
2019-07-19 16:06:47 -07:00
Lukacs T. Berki e341d4c655 Make .proto import path computation work with virtual protos in the main repository.
Also fix grammar.
2019-07-10 13:52:08 -07:00
Lukacs T. Berki b220178515 java_grpc_library.bzl: Work with proto_library rules using strip_import_prefix / import_prefix
In addition to this welcome functionality, this change also makes it
possible to fix http://github.com/bazelbuild/bazel/issues/7157 by
tolerating proto_library rules using a virtual import directory.
2019-07-09 13:04:10 -07:00
Eric Anderson a284cff892 java_grpc_library: Swap to descriptor_set_in to protoc
This avoids re-parsing the proto files and allows proto_library
to enforce more checks.

This is an export of cl/197343148
2019-06-07 07:27:01 -07:00
Eric Anderson 5d0c283b46 java_grpc_library.bzl: Support alternative javac toolchains
Depending on jdk:toolchain causes java_grpc_library to always use the
_default_ toolchain, even if the user tried to override it. Changing to
:current_java_toolchain allows the rule to use the user-selected
toolchain when overridden.

Tested by adding to BUILD:
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
default_java_toolchain(
    name = "mychain",
    misc = ["-Amy=flag"],
    visibility = ["//visibility:public"],
)

And then verifying -Amy=flag is in the output of:
bazel aquery --java_toolchain=:mychain services:_reflection_java_grpc

Fixes #5841
2019-06-06 15:31:31 -07:00
Eric Anderson 1214781995 java_grpc_library.bzl: Fix docstring to match Bazel style
https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#function-docstring-header

Made some additional changes to make the doc more clear.
2019-04-23 14:50:23 -07:00
Eric Anderson 745aa0a2f5 java_grpc_library: Use toolchain to enable DexArchiveAspect
This removes the "java_import to work around error with android_binary"
hack; see the b/78647825 references to see the really important parts.
But in general using a toolchain cleans up the code considerably and
allows us to reduce the visibility of our protoc plugin. It also is
useful to enable using aspects in the future to avoid using
make_non_strict() which would improve compilation speed avoid avoid many
unnecessary rebuilds.

This is an export of cl/229763103 and brings external up-to-sync with
internal.
2019-04-23 09:13:20 -07:00
Jihun Cho b6d7f6e84f
all: fix lint errors (#5462) 2019-03-11 10:52:12 -07:00
Eric Anderson c63752789e java_grpc_library.bzl: Pre-migrate for Bazel incompatible_use_toolchain_providers_in_java_common
This doesn't actually yet work with
--incompatible_use_toolchain_providers_in_java_common, as Bazel 0.23 didn't
include enough pieces. But this will work in 0.24 with the flag flipped. In
both cases it will continue working if the flag is not specified.

See https://github.com/grpc/grpc-java/issues/5383#issuecomment-470357965 and
https://github.com/bazelbuild/bazel/issues/7186
2019-03-07 18:09:53 -07:00
Liam Miller-Cushon 952a767b9c Rename source jar outputs to avoid conflicts with java_common.compile
More information: https://github.com/bazelbuild/bazel/issues/5824
2019-03-05 08:44:22 -07:00
Rodrigo Queiro 0959a846c8 bazel: update to new ProtoInfo provider
This is part of #5383. As Bazel 0.22.0 is the only supported version
now, use this in the Kokoro build.
2019-02-28 21:30:48 -07:00
Rodrigo Queiro 054def3c63 Use newer Bazel actions API
Also pass in the binary correctly as a tool. This is required for #5383.

I have tested the build with older Bazel versions and this doesn't
appear to affect compatibility, ie grpc-java continues to be compatible
with Bazel >=0.19.
2019-02-28 20:47:15 -07:00
Eric Anderson efa2e47335
java_grpc_library.bzl: workaround strict_deps
This is a sync from our internal copy, so has lots of small changes.
But the most important change is strict_deps issues are worked around
within the rule. This means there should be no longer any reason to
specify more than one dep.

Our Bazel CI is still on Bazel 0.20, so for the moment avoid requiring
Bazel 0.22 by staying on the old 'proto' provider instead of ProtoInfo.

Fixes #5314
2019-02-11 15:17:34 -08:00
Carl Mastrangelo 6c8020e584
all: fix formatting on bzl file 2019-01-25 16:13:46 -08:00
David Ostrovsky 23fcedfb6f Bazel: Fix compilation in Java 9
Fixes: #3633.

Test Plan:

On most recent Bazel version run:

  $ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk \
    build --javacopt='--release 9' \
    --java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 \
    examples:helloworld_java_grpc
2018-04-26 14:37:57 -07:00
Eric Anderson bace06fe9f
java_grpc_library: Add support for protobuf lite
gRPC's protobuf-lite auto-selects between full and lite protobuf based on the
value of crosstool_top. If the user is specifying their own
--android_crosstool_top, then it will not auto-detect correctly. One day,
platforms will fix problems like this, but for the moment it seems we get to
live with it.
2018-04-03 15:22:55 -07:00
Eric Anderson ef030abe6b java_grpc_library: re-add grpc-java repo to targets
They were removed in 137c74d1 since it was believed they were unnecessary.
However, since they are in a macro and not a rule, they are relative to the
caller, not their definition.

Added building the examples to the kokoro CI. Note that this means the examples
are built twice: once in grpc-java's build and once in their own (because it
has a WORKSPACE). Given that the Bazel build is our fastest build, this
slowdown won't probably be an issue.
2018-04-03 08:42:40 -07:00
Carmi Grushko 137c74d15f Drop @grpc_java from labels
These don't contribute if grpc-java is imported with name = grpc_java,
and break the build if grpc-java is imported with another name.
2018-02-21 15:14:17 -08:00
Rodrigo Queiro 2fb5d53d1b bazel: Remove com_google_protobuf_java
This was deprecated with Bazel 0.8.0, which now uses
@com_google_protobuf instead.

This change will break users that use
grpc_java_repositories(omit_com_google_protobuf_java=True), so I've
added a custom error message to make the resolution clearer.
2018-01-09 11:02:03 -08:00
Eric Anderson 3936557e72 java_grpc_library: fix remote protos that are 'src's
'includes' were already handled, but not 'src's. This allows you to
depend on things like :any_proto from the protobuf repo.

Fixes #3650
2017-11-06 17:29:12 -08:00
Brendan Linn 131a0ff39a java_grpc_library.bzl: fix path-manipulation bug.
_path_ignoring_repository munges bazel filesystem paths into proto
import paths, in order to pass to protoc -I. Currently, the function
assumes that the include's path begins with the bazel workspace root,
which can therefore be sheared off the front of the path.

This assumption is incorrect. For an include living in an external
repository (say, `@com_google_protobuf//:timestamp_proto`),
the filesystem path is something like
`bazel-out/darwin_x86_64-fastbuild/genfiles/external/com_google_protobuf/google/protobuf/timestamp.proto`.
(See also:
http://docs.bazel.build/versions/master/skylark/lib/Label.html#workspace_root.)
This commit changes _path_ignoring_repository to handle this case correctly.
2017-09-21 13:23:17 -07:00
Paul Gross 72b9ee22b8 all: Fix mismatch in naming Bazel Maven jars
This commit aligns the naming of the Bazel Maven jars with the names
used by Bazel's migration-tooling project:

https://github.com/bazelbuild/migration-tooling

Unfortunately, we can't fix @com_google_protobuf_java because it's
required by Bazel itself.

Fixes #3328
2017-08-11 16:39:43 -07:00
Simon Horlick 6d9e149dcb build: Add Bazel java_grpc_library rule
Bazel third party dependencies are specified in repositories.bzl which
gives the consumer the ability to opt-out of any dependencies they use
directly in their own project.

Fixes #2756
2017-06-22 13:06:49 -07:00