summaryrefslogtreecommitdiff
path: root/patches/Android.bp.patch
blob: d97431fd157d82bcdae1a1bfdfba154aab2e71cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
diff --git a/Android.bp b/Android.bp
index 45707bc..d0369e6 100644
--- a/Android.bp
+++ b/Android.bp
@@ -40,7 +40,10 @@
     host_supported: true,
     crate_name: "grpcio_sys",
     cargo_env_compat: true,
-    srcs: ["src/lib.rs"],
+    srcs: [
+        "src/lib.rs",
+        ":libgrpc_bindgen",
+    ],
     edition: "2018",
     features: [
         "bindgen",
@@ -55,52 +55,75 @@
         "liblibc",
         "liblibz_sys",
     ],
-    static_libs: [
-        "libabsl_bad_optional_access",
-        "libabsl_bad_variant_access",
-        "libabsl_base",
-        "libabsl_city",
-        "libabsl_civil_time",
-        "libabsl_cord",
-        "libabsl_debugging_internal",
-        "libabsl_demangle_internal",
-        "libabsl_exponential_biased",
-        "libabsl_graphcycles_internal",
-        "libabsl_hash",
-        "libabsl_hashtablez_sampler",
-        "libabsl_int128",
-        "libabsl_log_severity",
-        "libabsl_malloc_internal",
-        "libabsl_raw_hash_set",
-        "libabsl_raw_logging_internal",
-        "libabsl_spinlock_wait",
-        "libabsl_stacktrace",
-        "libabsl_status",
-        "libabsl_statusor",
-        "libabsl_str_format_internal",
-        "libabsl_strings",
-        "libabsl_strings_internal",
-        "libabsl_symbolize",
-        "libabsl_synchronization",
-        "libabsl_throw_delegate",
-        "libabsl_time",
-        "libabsl_time_zone",
-        "libabsl_wyhash",
-        "libaddress_sorting",
-        "libcares",
-        "libcrypto",
-        "libgpr",
-        "libgrpc",
-        "libgrpc_wrap",
-        "libre2",
-        "libssl",
-        "libupb",
-        "libz",
+    shared_libs: [
+        "libgrpc++",
+        "libgrpc_wrap"
     ],
-    shared_libs: ["libstdc++"],
     apex_available: [
         "//apex_available:platform",
         "com.android.bluetooth",
     ],
     min_sdk_version: "29",
 }
+
+cc_defaults {
+    name: "libgrpcio_sys_defaults",
+    cflags: [
+        "-DGRPC_SYS_SECURE",
+    ],
+    cpp_std: "c++11",
+    shared_libs: ["libgrpc++"],
+    apex_available: [
+        "//apex_available:platform",
+        "com.android.bluetooth",
+    ],
+    min_sdk_version: "29",
+}
+
+cc_library {
+    name: "libgrpc_wrap",
+    defaults: ["libgrpcio_sys_defaults"],
+    host_supported: true,
+    srcs: ["grpc_wrap.cc"],
+}
+
+rust_bindgen {
+    name: "libgrpc_bindgen",
+    defaults: ["libgrpcio_sys_defaults"],
+    host_supported: true,
+    wrapper_src: "android/bindgen_wrapper.hpp",
+    source_stem: "grpc-bindings",
+    crate_name: "grpc_bindgen",
+    bindgen_flags: [
+        "--size_t-is-usize",
+        "--constified-enum-module grpc_status_code",
+        "--default-enum-style rust",
+        "--allowlist-function=\\bgrpc_.*",
+        "--allowlist-function=\\bgpr_.*",
+        "--allowlist-function=\\bgrpcwrap_.*",
+        "--allowlist-var=\\bGRPC_.*",
+        "--allowlist-type=\\bgrpc_.*",
+        "--allowlist-type=\\bgpr_.*",
+        "--allowlist-type=\\bgrpcwrap_.*",
+        "--allowlist-type=\\bcensus_context.*",
+        "--allowlist-type=\\bverify_peer_options.*",
+        "--blocklist-type=(__)?pthread.*",
+        "--blocklist-function=\\bgpr_mu_.*",
+        "--blocklist-function=\\bgpr_cv_.*",
+        "--blocklist-function=\\bgpr_once_.*",
+        "--blocklist-type=gpr_mu",
+        "--blocklist-type=gpr_cv",
+        "--blocklist-type=gpr_once",
+    ],
+    min_sdk_version: "29",
+}
+
+rust_test {
+    name: "libgrpc_bindgen_test",
+    srcs: [":libgrpc_bindgen"],
+    crate_name: "grpc_bindgen_test",
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    clippy_lints: "none",
+    lints: "none",
+}