blob: ecb044e589f01a7c99afaa049f6665916b48df77 [file] [log] [blame]
Bob Badour3c538232021-02-12 21:26:48 -08001package {
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
Stephen Crane2a3c2502020-06-16 17:48:35 -070010rust_library {
11 name: "libbinder_rs",
12 crate_name: "binder",
13 srcs: ["src/lib.rs"],
14 shared_libs: [
Stephen Crane2a3c2502020-06-16 17:48:35 -070015 "libutils",
16 ],
17 rustlibs: [
18 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -070019 "libbinder_ndk_sys",
Andrei Homescuea406212021-09-03 02:55:00 +000020 "libdowncast_rs",
Stephen Crane994a0f02020-08-11 14:47:29 -070021 ],
22 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070023 target: {
24 darwin: {
25 enabled: false,
26 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090027 },
28 apex_available: [
29 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -070030 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +090031 "com.android.virt",
32 ],
Stephen Crane994a0f02020-08-11 14:47:29 -070033}
34
35rust_library {
36 name: "libbinder_ndk_sys",
37 crate_name: "binder_ndk_sys",
38 srcs: [
39 "sys/lib.rs",
40 ":libbinder_ndk_bindgen",
41 ],
42 shared_libs: [
43 "libbinder_ndk",
Stephen Crane2a3c2502020-06-16 17:48:35 -070044 ],
45 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070046 target: {
47 darwin: {
48 enabled: false,
49 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090050 },
51 apex_available: [
52 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -070053 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +090054 "com.android.virt",
55 ],
ThiƩbaud Weksteen3160ce92021-04-29 20:54:39 +020056 lints: "none",
57 clippy_lints: "none",
Stephen Crane2a3c2502020-06-16 17:48:35 -070058}
59
60rust_bindgen {
61 name: "libbinder_ndk_bindgen",
62 crate_name: "binder_ndk_bindgen",
Ivan Lozano7929c082020-09-23 13:33:42 -040063 wrapper_src: "sys/BinderBindings.hpp",
Stephen Crane994a0f02020-08-11 14:47:29 -070064 source_stem: "bindings",
Stephen Crane2a3c2502020-06-16 17:48:35 -070065 bindgen_flags: [
66 // Unfortunately the only way to specify the rust_non_exhaustive enum
67 // style for a type is to make it the default
68 "--default-enum-style", "rust_non_exhaustive",
69 // and then specify constified enums for the enums we don't want
70 // rustified
71 "--constified-enum", "android::c_interface::consts::.*",
72
Joel Galenson6ad53242021-04-19 09:39:12 -070073 "--allowlist-type", "android::c_interface::.*",
74 "--allowlist-type", "AStatus",
75 "--allowlist-type", "AIBinder_Class",
76 "--allowlist-type", "AIBinder",
77 "--allowlist-type", "AIBinder_Weak",
78 "--allowlist-type", "AIBinder_DeathRecipient",
79 "--allowlist-type", "AParcel",
80 "--allowlist-type", "binder_status_t",
81 "--allowlist-function", ".*",
Stephen Crane2a3c2502020-06-16 17:48:35 -070082 ],
83 shared_libs: [
84 "libbinder_ndk",
85 ],
86 host_supported: true,
87
88 // Currently necessary for host builds
89 // TODO(b/31559095): bionic on host should define this
90 target: {
91 host: {
92 cflags: [
93 "-D__INTRODUCED_IN(n)=",
94 "-D__assert(a,b,c)=",
95 // We want all the APIs to be available on the host.
96 "-D__ANDROID_API__=10000",
97 ],
98 },
Yifan Hongf856a982020-10-30 14:51:17 -070099 darwin: {
100 enabled: false,
101 },
Stephen Crane2a3c2502020-06-16 17:48:35 -0700102 },
Jiyong Parkb1af7832021-02-16 13:30:57 +0900103 apex_available: [
104 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -0700105 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +0900106 "com.android.virt",
107 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -0700108}
109
Victor Hsiehd35d31d2021-06-03 11:24:31 -0700110// TODO(b/184872979): remove once the Rust API is created.
111rust_bindgen {
112 name: "libbinder_rpc_unstable_bindgen",
Inseob Kim01befc82021-08-31 20:28:50 +0900113 wrapper_src: ":libbinder_rpc_unstable_header",
Victor Hsiehd35d31d2021-06-03 11:24:31 -0700114 crate_name: "binder_rpc_unstable_bindgen",
115 source_stem: "bindings",
116 shared_libs: [
117 "libutils",
118 ],
119 apex_available: [
120 "com.android.compos",
121 "com.android.virt",
122 ],
123}
124
Stephen Crane2a3c2502020-06-16 17:48:35 -0700125rust_test {
126 name: "libbinder_rs-internal_test",
127 crate_name: "binder",
128 srcs: ["src/lib.rs"],
129 test_suites: ["general-tests"],
130 auto_gen_config: true,
131 shared_libs: [
132 "libbinder_ndk",
133 ],
134 rustlibs: [
135 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -0700136 "libbinder_ndk_sys",
Andrei Homescuea406212021-09-03 02:55:00 +0000137 "libdowncast_rs",
Stephen Crane2a3c2502020-06-16 17:48:35 -0700138 ],
139}
Joel Galenson52c44da2021-08-23 09:19:35 -0700140
141rust_test {
142 name: "libbinder_ndk_bindgen_test",
143 srcs: [":libbinder_ndk_bindgen"],
144 crate_name: "binder_ndk_bindgen",
145 test_suites: ["general-tests"],
146 auto_gen_config: true,
147 clippy_lints: "none",
148 lints: "none",
149}
150
151rust_test {
152 name: "libbinder_rpc_unstable_bindgen_test",
153 srcs: [":libbinder_rpc_unstable_bindgen"],
154 crate_name: "binder_rpc_unstable_bindgen",
155 test_suites: ["general-tests"],
156 auto_gen_config: true,
157 clippy_lints: "none",
158 lints: "none",
159}