blob: 8d27eedb57bba3f079a4901b07ba05ed986a1ea6 [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",
20 ],
21 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070022 target: {
23 darwin: {
24 enabled: false,
25 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090026 },
27 apex_available: [
28 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -070029 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +090030 "com.android.virt",
31 ],
Stephen Crane994a0f02020-08-11 14:47:29 -070032}
33
34rust_library {
35 name: "libbinder_ndk_sys",
36 crate_name: "binder_ndk_sys",
37 srcs: [
38 "sys/lib.rs",
39 ":libbinder_ndk_bindgen",
40 ],
41 shared_libs: [
42 "libbinder_ndk",
Stephen Crane2a3c2502020-06-16 17:48:35 -070043 ],
44 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070045 target: {
46 darwin: {
47 enabled: false,
48 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090049 },
50 apex_available: [
51 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -070052 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +090053 "com.android.virt",
54 ],
ThiƩbaud Weksteen3160ce92021-04-29 20:54:39 +020055 lints: "none",
56 clippy_lints: "none",
Stephen Crane2a3c2502020-06-16 17:48:35 -070057}
58
59rust_bindgen {
60 name: "libbinder_ndk_bindgen",
61 crate_name: "binder_ndk_bindgen",
Ivan Lozano7929c082020-09-23 13:33:42 -040062 wrapper_src: "sys/BinderBindings.hpp",
Stephen Crane994a0f02020-08-11 14:47:29 -070063 source_stem: "bindings",
Stephen Crane2a3c2502020-06-16 17:48:35 -070064 bindgen_flags: [
65 // Unfortunately the only way to specify the rust_non_exhaustive enum
66 // style for a type is to make it the default
67 "--default-enum-style", "rust_non_exhaustive",
68 // and then specify constified enums for the enums we don't want
69 // rustified
70 "--constified-enum", "android::c_interface::consts::.*",
71
Joel Galenson6ad53242021-04-19 09:39:12 -070072 "--allowlist-type", "android::c_interface::.*",
73 "--allowlist-type", "AStatus",
74 "--allowlist-type", "AIBinder_Class",
75 "--allowlist-type", "AIBinder",
76 "--allowlist-type", "AIBinder_Weak",
77 "--allowlist-type", "AIBinder_DeathRecipient",
78 "--allowlist-type", "AParcel",
79 "--allowlist-type", "binder_status_t",
80 "--allowlist-function", ".*",
Stephen Crane2a3c2502020-06-16 17:48:35 -070081 ],
82 shared_libs: [
83 "libbinder_ndk",
84 ],
85 host_supported: true,
86
87 // Currently necessary for host builds
88 // TODO(b/31559095): bionic on host should define this
89 target: {
90 host: {
91 cflags: [
92 "-D__INTRODUCED_IN(n)=",
93 "-D__assert(a,b,c)=",
94 // We want all the APIs to be available on the host.
95 "-D__ANDROID_API__=10000",
96 ],
97 },
Yifan Hongf856a982020-10-30 14:51:17 -070098 darwin: {
99 enabled: false,
100 },
Stephen Crane2a3c2502020-06-16 17:48:35 -0700101 },
Jiyong Parkb1af7832021-02-16 13:30:57 +0900102 apex_available: [
103 "//apex_available:platform",
Victor Hsieh7d7de5b2021-05-10 16:28:54 -0700104 "com.android.compos",
Jiyong Parkb1af7832021-02-16 13:30:57 +0900105 "com.android.virt",
106 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -0700107}
108
Victor Hsiehd35d31d2021-06-03 11:24:31 -0700109// TODO(b/184872979): remove once the Rust API is created.
110rust_bindgen {
111 name: "libbinder_rpc_unstable_bindgen",
112 wrapper_src: "src/binder_rpc_unstable.hpp",
113 crate_name: "binder_rpc_unstable_bindgen",
114 source_stem: "bindings",
115 shared_libs: [
116 "libutils",
117 ],
118 apex_available: [
119 "com.android.compos",
120 "com.android.virt",
121 ],
122}
123
Stephen Crane2a3c2502020-06-16 17:48:35 -0700124rust_test {
125 name: "libbinder_rs-internal_test",
126 crate_name: "binder",
127 srcs: ["src/lib.rs"],
128 test_suites: ["general-tests"],
129 auto_gen_config: true,
130 shared_libs: [
131 "libbinder_ndk",
132 ],
133 rustlibs: [
134 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -0700135 "libbinder_ndk_sys",
Stephen Crane2a3c2502020-06-16 17:48:35 -0700136 ],
137}