blob: 57c9013f60c9a791b8a21eecd4c872867f410c69 [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",
29 "com.android.virt",
30 ],
Stephen Crane994a0f02020-08-11 14:47:29 -070031}
32
33rust_library {
34 name: "libbinder_ndk_sys",
35 crate_name: "binder_ndk_sys",
36 srcs: [
37 "sys/lib.rs",
38 ":libbinder_ndk_bindgen",
39 ],
40 shared_libs: [
41 "libbinder_ndk",
Stephen Crane2a3c2502020-06-16 17:48:35 -070042 ],
43 host_supported: true,
Yifan Hongf856a982020-10-30 14:51:17 -070044 target: {
45 darwin: {
46 enabled: false,
47 }
Jiyong Parkb1af7832021-02-16 13:30:57 +090048 },
49 apex_available: [
50 "//apex_available:platform",
51 "com.android.virt",
52 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -070053}
54
55rust_bindgen {
56 name: "libbinder_ndk_bindgen",
57 crate_name: "binder_ndk_bindgen",
Ivan Lozano7929c082020-09-23 13:33:42 -040058 wrapper_src: "sys/BinderBindings.hpp",
Stephen Crane994a0f02020-08-11 14:47:29 -070059 source_stem: "bindings",
Stephen Crane2a3c2502020-06-16 17:48:35 -070060 bindgen_flags: [
61 // Unfortunately the only way to specify the rust_non_exhaustive enum
62 // style for a type is to make it the default
63 "--default-enum-style", "rust_non_exhaustive",
64 // and then specify constified enums for the enums we don't want
65 // rustified
66 "--constified-enum", "android::c_interface::consts::.*",
67
Joel Galenson6ad53242021-04-19 09:39:12 -070068 "--allowlist-type", "android::c_interface::.*",
69 "--allowlist-type", "AStatus",
70 "--allowlist-type", "AIBinder_Class",
71 "--allowlist-type", "AIBinder",
72 "--allowlist-type", "AIBinder_Weak",
73 "--allowlist-type", "AIBinder_DeathRecipient",
74 "--allowlist-type", "AParcel",
75 "--allowlist-type", "binder_status_t",
76 "--allowlist-function", ".*",
Stephen Crane2a3c2502020-06-16 17:48:35 -070077 ],
78 shared_libs: [
79 "libbinder_ndk",
80 ],
81 host_supported: true,
82
83 // Currently necessary for host builds
84 // TODO(b/31559095): bionic on host should define this
85 target: {
86 host: {
87 cflags: [
88 "-D__INTRODUCED_IN(n)=",
89 "-D__assert(a,b,c)=",
90 // We want all the APIs to be available on the host.
91 "-D__ANDROID_API__=10000",
92 ],
93 },
Yifan Hongf856a982020-10-30 14:51:17 -070094 darwin: {
95 enabled: false,
96 },
Stephen Crane2a3c2502020-06-16 17:48:35 -070097 },
Jiyong Parkb1af7832021-02-16 13:30:57 +090098 apex_available: [
99 "//apex_available:platform",
100 "com.android.virt",
101 ],
Stephen Crane2a3c2502020-06-16 17:48:35 -0700102}
103
104rust_test {
105 name: "libbinder_rs-internal_test",
106 crate_name: "binder",
107 srcs: ["src/lib.rs"],
108 test_suites: ["general-tests"],
109 auto_gen_config: true,
110 shared_libs: [
111 "libbinder_ndk",
112 ],
113 rustlibs: [
114 "liblibc",
Stephen Crane994a0f02020-08-11 14:47:29 -0700115 "libbinder_ndk_sys",
Stephen Crane2a3c2502020-06-16 17:48:35 -0700116 ],
117}