Skip to content

Commit 697855c

Browse files
committed
binder: bazel support (bzlmod mode only)
1 parent 3e8eae1 commit 697855c

5 files changed

Lines changed: 61 additions & 3 deletions

File tree

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
2+
3+
common:skip_android --deleted_packages=binder

.github/workflows/testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ jobs:
100100
key: ${{ runner.os }}-bazel-${{ env.USE_BAZEL_VERSION }}-${{ hashFiles('WORKSPACE', 'repositories.bzl') }}
101101

102102
- name: Run bazel build
103-
run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
103+
run: bazelisk build //... --config=skip_android --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
104104

105105
- name: Run bazel test
106-
run: bazelisk test //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
106+
run: bazelisk test //... --config=skip_android --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}
107107

108108
- name: Run example bazel build
109109
run: bazelisk build //... --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }}

MODULE.bazel

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,45 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [
4646
]
4747
# GRPC_DEPS_END
4848

49+
ANDROID_ARTIFACTS = [
50+
"androidx.annotation:annotation:1.6.0",
51+
"androidx.annotation:annotation-jvm:1.6.0",
52+
"androidx.core:core:1.13.1",
53+
"androidx.lifecycle:lifecycle-common:2.6.2",
54+
"androidx.test:core:1.7.0",
55+
"androidx.test.ext:junit:1.2.1",
56+
"androidx.test:runner:1.6.1",
57+
"androidx.test:rules:1.6.1",
58+
"org.robolectric:android-all:14-robolectric-10818077",
59+
"org.robolectric:annotations:4.16.1",
60+
"org.robolectric:robolectric:4.16.1",
61+
"org.robolectric:shadows-framework:4.16.1",
62+
]
63+
4964
bazel_dep(name = "abseil-cpp", version = "20250512.1")
5065
bazel_dep(name = "bazel_jar_jar", version = "0.1.11.bcr.1")
5166
bazel_dep(name = "bazel_skylib", version = "1.7.1")
5267
bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5", repo_name = "com_google_googleapis")
5368
bazel_dep(name = "grpc-proto", version = "0.0.0-20240627-ec30f58.bcr.1", repo_name = "io_grpc_grpc_proto")
5469
bazel_dep(name = "protobuf", version = "33.4", repo_name = "com_google_protobuf")
70+
bazel_dep(name = "rules_android", version = "0.7.2")
5571
bazel_dep(name = "rules_cc", version = "0.0.9")
5672
bazel_dep(name = "rules_java", version = "9.1.0")
5773
bazel_dep(name = "rules_jvm_external", version = "6.0")
5874

75+
android_sdk_repository_extension = use_extension(
76+
"@rules_android//rules/android_sdk_repository:rule.bzl",
77+
"android_sdk_repository_extension",
78+
)
79+
use_repo(android_sdk_repository_extension, "androidsdk")
80+
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
81+
5982
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
6083
maven.install(
61-
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
84+
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + ANDROID_ARTIFACTS,
6285
repositories = [
6386
"https://repo.maven.apache.org/maven2/",
87+
"https://maven.google.com", # For androidx.*
6488
],
6589
strict_visibility = True,
6690
)
@@ -158,3 +182,7 @@ maven.override(
158182
coordinates = "io.grpc:grpc-util",
159183
target = "@io_grpc_grpc_java//util",
160184
)
185+
maven.override(
186+
coordinates = "io.grpc:grpc-binder",
187+
target = "@io_grpc_grpc_java//binder",
188+
)

WORKSPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ maven_install(
5353
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
5454
repositories = [
5555
"https://repo.maven.apache.org/maven2/",
56+
# "https://maven.google.com", # For androidx.*
5657
],
5758
strict_visibility = True,
5859
)

binder/BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@rules_android//rules:rules.bzl", "android_library")
2+
load("@rules_jvm_external//:defs.bzl", "artifact")
3+
4+
licenses(["notice"])
5+
6+
android_library(
7+
name = "binder",
8+
srcs = glob([
9+
"src/main/java/**/*.java",
10+
]),
11+
manifest = "src/main/AndroidManifest.xml",
12+
custom_package = "io.grpc.binder",
13+
visibility = ["//visibility:public"],
14+
exports = [artifact("androidx.annotation:annotation")],
15+
javacopts = ["-Xep:GuardedBy:ERROR"],
16+
deps = [
17+
"//api",
18+
"//core:internal",
19+
artifact("androidx.annotation:annotation"),
20+
"@maven//:androidx_annotation_annotation_jvm",
21+
artifact("androidx.core:core"),
22+
artifact("androidx.lifecycle:lifecycle-common"),
23+
artifact("com.google.code.findbugs:jsr305"),
24+
artifact("com.google.errorprone:error_prone_annotations"),
25+
artifact("com.google.guava:guava"),
26+
],
27+
)

0 commit comments

Comments
 (0)