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