| // Copyright (C) 2025 The Android Open Source Project | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| package { | |
| default_team: "trendy_team_fwk_core_networking", | |
| } | |
| genrule { | |
| name: "libdns_proxy_cxx_bridge_header", | |
| tools: ["cxxbridge"], | |
| cmd: "$(location cxxbridge) $(in) --header >> $(out)", | |
| srcs: ["src/dns_proxy/ffi.rs"], | |
| out: ["dns_proxy_cxx_bridge.rs.h"], | |
| } | |
| genrule { | |
| name: "libdns_proxy_cxx_bridge_source", | |
| tools: ["cxxbridge"], | |
| cmd: "$(location cxxbridge) $(in) >> $(out)", | |
| srcs: ["src/dns_proxy/ffi.rs"], | |
| out: ["dns_proxy_cxx_bridge.rs.cpp"], | |
| } | |
| cc_library_static { | |
| name: "libdns_proxy_cxx_bridge", | |
| defaults: ["netd_defaults"], | |
| include_dirs: ["packages/modules/DnsResolver"], | |
| srcs: ["src/dns_proxy/net_context_client.cpp"], | |
| generated_headers: [ | |
| "cxx-bridge-header", | |
| "libdns_proxy_cxx_bridge_header", | |
| ], | |
| export_generated_headers: [ | |
| "cxx-bridge-header", | |
| "libdns_proxy_cxx_bridge_header", | |
| ], | |
| generated_sources: ["libdns_proxy_cxx_bridge_source"], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| genrule { | |
| name: "libdns_proxy_test_cxx_bridge_header", | |
| tools: ["cxxbridge"], | |
| cmd: "$(location cxxbridge) $(in) --header --cfg 'feature=\"ffi-test-only\"' >> $(out)", | |
| srcs: ["src/dns_proxy/ffi.rs"], | |
| out: ["dns_proxy_cxx_bridge.rs.h"], | |
| } | |
| genrule { | |
| name: "libdns_proxy_test_cxx_bridge_source", | |
| tools: ["cxxbridge"], | |
| cmd: "$(location cxxbridge) $(in) --cfg 'feature=\"ffi-test-only\"' >> $(out)", | |
| srcs: ["src/dns_proxy/ffi.rs"], | |
| out: ["dns_proxy_cxx_bridge.rs.cpp"], | |
| } | |
| cc_library_static { | |
| name: "libdns_proxy_test_cxx_bridge", | |
| defaults: ["netd_defaults"], | |
| include_dirs: ["packages/modules/DnsResolver"], | |
| srcs: ["src/dns_proxy/net_context_client.cpp"], | |
| generated_headers: [ | |
| "cxx-bridge-header", | |
| "libdns_proxy_test_cxx_bridge_header", | |
| ], | |
| export_generated_headers: [ | |
| "cxx-bridge-header", | |
| "libdns_proxy_test_cxx_bridge_header", | |
| ], | |
| generated_sources: ["libdns_proxy_test_cxx_bridge_source"], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| rust_defaults { | |
| name: "resolvrs_defaults", | |
| crate_name: "resolvrs", | |
| edition: "2021", | |
| srcs: ["src/lib.rs"], | |
| features: ["statslog"], | |
| rlibs: [ | |
| "libandroid_logger", | |
| "libcxx", | |
| "libanyhow", | |
| "libbytes", | |
| "libcommand_fds", | |
| "libfutures", | |
| "liblog_rust", | |
| "libnix", | |
| "libnum_enum", | |
| "librand", | |
| "libsocket2", | |
| "libthiserror", | |
| "libtokio", | |
| "libtokio_util", | |
| "libbase64_rust", | |
| "liblibc", | |
| "libring", | |
| "libresolvrs_utils", | |
| "libstatic_assertions", | |
| "libstatslog_dns_resolver_rust", | |
| "liburl", | |
| ], | |
| shared_libs: [ | |
| "libcrypto", | |
| "libssl", | |
| ], | |
| sanitize: { | |
| // Rust libraries statically linked into C++ fuzzers must set fuzzer: false to avoid | |
| // duplicate libFuzzer entrypoints and conflicting sanitizer runtime symbol definitions. | |
| fuzzer: false, | |
| }, | |
| } | |
| rust_ffi_static { | |
| name: "libresolvrs_ffi", | |
| defaults: ["resolvrs_defaults"], | |
| features: [ | |
| "android-ffi", | |
| "dns_proxy", | |
| ], | |
| prefer_rlib: true, | |
| rlibs: [ | |
| "libcxx", | |
| ], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| rust_ffi_static { | |
| name: "libresolvrs_test_ffi", | |
| defaults: ["resolvrs_defaults"], | |
| features: [ | |
| "android-ffi", | |
| "dns_proxy", | |
| "ffi-test-only", | |
| ], | |
| prefer_rlib: true, | |
| rlibs: [ | |
| "libcxx", | |
| ], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| // Soong's `dist` rule copies all `.so` files from test data directories into `$DIST_DIR` | |
| // solely by filename. Consequently, if multiple test targets declare the same shared library | |
| // in `data_libs` (e.g. `libresolvrs_doh_ffi`), `m dist` fails with conflicting dist sources | |
| // because each test produces an output copy with the identical basename. | |
| // To avoid filename conflicts during dist packaging while still pushing libraries to test | |
| // devices, we define `rust_defaults` and declare uniquely named `rust_ffi_shared` copies | |
| // for each test module that dynamically loads DoH (see b/529600820). | |
| rust_defaults { | |
| name: "libresolvrs_doh_ffi_defaults", | |
| defaults: ["resolvrs_defaults"], | |
| features: [ | |
| "android-ffi", | |
| "doh", | |
| ], | |
| prefer_rlib: true, | |
| rlibs: [ | |
| "libcxx", | |
| "libquiche-0.17", | |
| ], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| rust_defaults { | |
| name: "libresolvrs_doh_ffi_q24_defaults", | |
| defaults: ["resolvrs_defaults"], | |
| features: [ | |
| "android-ffi", | |
| "doh", | |
| "quiche_0_24", | |
| ], | |
| prefer_rlib: true, | |
| rlibs: [ | |
| "libcxx", | |
| "libquiche", | |
| ], | |
| apex_available: ["com.android.tethering"], | |
| min_sdk_version: "apex_inherit", | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi", | |
| defaults: ["libresolvrs_doh_ffi_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_q24", | |
| defaults: ["libresolvrs_doh_ffi_q24_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_for_resolv_unit_test", | |
| defaults: ["libresolvrs_doh_ffi_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_q24_for_resolv_unit_test", | |
| defaults: ["libresolvrs_doh_ffi_q24_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_for_doh_ffi_test", | |
| defaults: ["libresolvrs_doh_ffi_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_q24_for_doh_ffi_test", | |
| defaults: ["libresolvrs_doh_ffi_q24_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_for_resolv_gold_test", | |
| defaults: ["libresolvrs_doh_ffi_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_for_resolv_fuzzer", | |
| defaults: ["libresolvrs_doh_ffi_defaults"], | |
| } | |
| rust_ffi_shared { | |
| name: "libresolvrs_doh_ffi_q24_for_resolv_fuzzer", | |
| defaults: ["libresolvrs_doh_ffi_q24_defaults"], | |
| } | |
| cc_defaults { | |
| name: "libresolvrs_ffi_defaults", | |
| static_libs: [ | |
| "libresolvrs_ffi", | |
| "libdns_proxy_cxx_bridge", | |
| ], | |
| } | |
| cc_defaults { | |
| name: "libresolvrs_test_ffi_defaults", | |
| static_libs: [ | |
| "libresolvrs_test_ffi", | |
| "libdns_proxy_test_cxx_bridge", | |
| ], | |
| cflags: [ | |
| "-DDNS_PROXY_FFI_TEST", | |
| ], | |
| } | |
| rust_test { | |
| name: "resolvrs_unit_test", | |
| defaults: ["resolvrs_defaults"], | |
| features: [ | |
| "dns_proxy", | |
| "doh", | |
| ], | |
| test_suites: ["general-tests"], | |
| data: [ | |
| "testdata/a61fdd91.0", | |
| "testdata/key.pem", | |
| ], | |
| rlibs: [ | |
| "libquiche_static-0.17", | |
| "libmockall", | |
| ], | |
| shared_libs: ["libc++"], | |
| min_sdk_version: "apex_inherit", | |
| } |