• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "frameworks_native_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["frameworks_native_license"],
8}
9
10rust_library {
11    name: "libbinder_rs",
12    crate_name: "binder",
13    srcs: ["src/lib.rs"],
14    rustlibs: [
15        "libbinder_ndk_sys",
16        "libdowncast_rs",
17        "liblibc",
18        "liblog_rust",
19        "libzerocopy",
20    ],
21    host_supported: true,
22    vendor_available: true,
23    product_available: true,
24    target: {
25        darwin: {
26            enabled: false,
27        },
28    },
29    apex_available: [
30        "//apex_available:platform",
31        "//apex_available:anyapex",
32    ],
33    min_sdk_version: "Tiramisu",
34}
35
36rust_library {
37    name: "libbinder_rs_on_trusty_mock",
38    crate_name: "binder",
39    srcs: ["src/lib.rs"],
40    cfgs: [
41        "trusty",
42    ],
43    rustlibs: [
44        "libbinder_ndk_sys_on_trusty_mock",
45        "libdowncast_rs",
46        "liblibc",
47    ],
48    vendor: true,
49}
50
51rust_library {
52    name: "libbinder_tokio_rs",
53    crate_name: "binder_tokio",
54    srcs: ["binder_tokio/lib.rs"],
55    rustlibs: [
56        "libbinder_rs",
57        "libtokio",
58    ],
59    host_supported: true,
60    vendor_available: true,
61    product_available: true,
62    target: {
63        darwin: {
64            enabled: false,
65        },
66    },
67    apex_available: [
68        "//apex_available:platform",
69        "//apex_available:anyapex",
70    ],
71    min_sdk_version: "Tiramisu",
72}
73
74rust_library {
75    name: "libbinder_ndk_sys",
76    crate_name: "binder_ndk_sys",
77    srcs: [
78        "sys/lib.rs",
79        ":libbinder_ndk_bindgen",
80    ],
81    shared_libs: [
82        "libbinder_ndk",
83    ],
84    rustlibs: [
85        "liblibc",
86    ],
87    host_supported: true,
88    vendor_available: true,
89    product_available: true,
90    target: {
91        darwin: {
92            enabled: false,
93        },
94    },
95    apex_available: [
96        "//apex_available:platform",
97        "//apex_available:anyapex",
98    ],
99    min_sdk_version: "Tiramisu",
100    lints: "none",
101    clippy_lints: "none",
102    visibility: [":__subpackages__"],
103}
104
105rust_library {
106    name: "libbinder_ndk_sys_on_trusty_mock",
107    crate_name: "binder_ndk_sys",
108    srcs: [
109        "sys/lib.rs",
110        ":libbinder_ndk_bindgen_on_trusty_mock",
111    ],
112    cfgs: [
113        "trusty",
114    ],
115    shared_libs: [
116        "libbinder_ndk_on_trusty_mock",
117    ],
118    vendor: true,
119    // Lints are checked separately for libbinder_ndk_sys.
120    // The Trusty mock copy pulls in extra headers that
121    // don't pass the lints for the bindgen output.
122    lints: "none",
123}
124
125rust_bindgen {
126    name: "libbinder_ndk_bindgen",
127    crate_name: "binder_ndk_bindgen",
128    wrapper_src: "sys/BinderBindings.hpp",
129    source_stem: "bindings",
130    bindgen_flag_files: [
131        // Unfortunately the only way to specify the rust_non_exhaustive enum
132        // style for a type is to make it the default
133        // and then specify constified enums for the enums we don't want
134        // rustified
135        "libbinder_ndk_bindgen_flags.txt",
136    ],
137    bindgen_flags: [
138        "--blocklist-type",
139        "sockaddr",
140        "--raw-line",
141        "use libc::sockaddr;",
142    ],
143    cflags: [
144        "-DANDROID_PLATFORM",
145    ],
146    shared_libs: [
147        "libbinder_ndk",
148    ],
149    rustlibs: [
150        "liblibc",
151    ],
152    host_supported: true,
153    vendor_available: true,
154    product_available: true,
155
156    // Currently necessary for host builds
157    // TODO(b/31559095): bionic on host should define this
158    target: {
159        darwin: {
160            enabled: false,
161        },
162    },
163    apex_available: [
164        "//apex_available:platform",
165        "//apex_available:anyapex",
166    ],
167    min_sdk_version: "Tiramisu",
168}
169
170rust_bindgen {
171    name: "libbinder_ndk_bindgen_on_trusty_mock",
172    crate_name: "binder_ndk_bindgen",
173    wrapper_src: "sys/BinderBindings.hpp",
174    source_stem: "bindings",
175    defaults: [
176        "trusty_mock_defaults",
177    ],
178
179    bindgen_flag_files: [
180        // Unfortunately the only way to specify the rust_non_exhaustive enum
181        // style for a type is to make it the default
182        // and then specify constified enums for the enums we don't want
183        // rustified
184        "libbinder_ndk_bindgen_flags.txt",
185    ],
186    cflags: [
187        "-DANDROID_PLATFORM",
188    ],
189    shared_libs: [
190        "libbinder_ndk_on_trusty_mock",
191        "libc++",
192    ],
193}
194
195rust_test {
196    name: "libbinder_rs-internal_test",
197    crate_name: "binder",
198    srcs: ["src/lib.rs"],
199    test_suites: ["general-tests"],
200    auto_gen_config: true,
201    shared_libs: [
202        "libbinder_ndk",
203    ],
204    rustlibs: [
205        "libbinder_ndk_sys",
206        "libdowncast_rs",
207        "liblibc",
208        "liblog_rust",
209        "libzerocopy",
210    ],
211}
212
213rust_test {
214    name: "libbinder_ndk_bindgen_test",
215    srcs: [":libbinder_ndk_bindgen"],
216    crate_name: "binder_ndk_bindgen",
217    test_suites: ["general-tests"],
218    auto_gen_config: true,
219    clippy_lints: "none",
220    lints: "none",
221    rustlibs: [
222        "liblibc",
223    ],
224}
225