blob: f804f1416a51442b230af9fa7e56b701baeed8ba [file] [log] [blame]
Stephen Crane2a3c2502020-06-16 17:48:35 -07001rust_library {
2 name: "libbinder_rs",
3 crate_name: "binder",
4 srcs: ["src/lib.rs"],
5 shared_libs: [
Stephen Crane2a3c2502020-06-16 17:48:35 -07006 "libutils",
7 ],
8 rustlibs: [
9 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -070010 "libbinder_ndk_sys",
11 ],
12 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070013 target: {
14 darwin: {
15 enabled: false,
16 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090017 },
18 apex_available: [
19 "//apex_available:platform",
20 "com.android.virt",
21 ],
Stephen Crane994a0f02020-08-11 14:47:29 -070022}
23
24rust_library {
25 name: "libbinder_ndk_sys",
26 crate_name: "binder_ndk_sys",
27 srcs: [
28 "sys/lib.rs",
29 ":libbinder_ndk_bindgen",
30 ],
31 shared_libs: [
32 "libbinder_ndk",
Stephen Crane2a3c2502020-06-16 17:48:35 -070033 ],
34 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070035 target: {
36 darwin: {
37 enabled: false,
38 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090039 },
40 apex_available: [
41 "//apex_available:platform",
42 "com.android.virt",
43 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -070044}
45
46rust_bindgen {
47 name: "libbinder_ndk_bindgen",
48 crate_name: "binder_ndk_bindgen",
Ivan Lozano7929c082020-09-23 13:33:42 -040049 wrapper_src: "sys/BinderBindings.hpp",
Stephen Crane994a0f02020-08-11 14:47:29 -070050 source_stem: "bindings",
Stephen Crane2a3c2502020-06-16 17:48:35 -070051 bindgen_flags: [
52 // Unfortunately the only way to specify the rust_non_exhaustive enum
53 // style for a type is to make it the default
54 "--default-enum-style", "rust_non_exhaustive",
55 // and then specify constified enums for the enums we don't want
56 // rustified
57 "--constified-enum", "android::c_interface::consts::.*",
58
59 "--whitelist-type", "android::c_interface::.*",
60 "--whitelist-type", "AStatus",
61 "--whitelist-type", "AIBinder_Class",
62 "--whitelist-type", "AIBinder",
63 "--whitelist-type", "AIBinder_Weak",
64 "--whitelist-type", "AIBinder_DeathRecipient",
65 "--whitelist-type", "AParcel",
66 "--whitelist-type", "binder_status_t",
67 "--whitelist-function", ".*",
68 ],
69 shared_libs: [
70 "libbinder_ndk",
71 ],
72 host_supported: true,
73
74 // Currently necessary for host builds
75 // TODO(b/31559095): bionic on host should define this
76 target: {
77 host: {
78 cflags: [
79 "-D__INTRODUCED_IN(n)=",
80 "-D__assert(a,b,c)=",
81 // We want all the APIs to be available on the host.
82 "-D__ANDROID_API__=10000",
83 ],
84 },
Yifan Hongf856a982020-10-30 14:51:17 -070085 darwin: {
86 enabled: false,
87 },
Stephen Crane2a3c2502020-06-16 17:48:35 -070088 },
Jiyong Parkb1af7832021-02-16 13:30:57 +090089 apex_available: [
90 "//apex_available:platform",
91 "com.android.virt",
92 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -070093}
94
95rust_test {
96 name: "libbinder_rs-internal_test",
97 crate_name: "binder",
98 srcs: ["src/lib.rs"],
99 test_suites: ["general-tests"],
100 auto_gen_config: true,
101 shared_libs: [
102 "libbinder_ndk",
103 ],
104 rustlibs: [
105 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -0700106 "libbinder_ndk_sys",
Stephen Crane2a3c2502020-06-16 17:48:35 -0700107 ],
108}