• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_applicable_licenses: ["packages_modules_DnsResolver_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18// See: http://go/android-license-faq
19license {
20    name: "packages_modules_DnsResolver_license",
21    visibility: [":__subpackages__"],
22    license_kinds: [
23        "SPDX-license-identifier-Apache-2.0",
24        "SPDX-license-identifier-BSD",
25        "SPDX-license-identifier-ISC",
26        "SPDX-license-identifier-MIT",
27    ],
28    license_text: [
29        "NOTICE",
30    ],
31}
32
33cc_library_headers {
34    name: "libnetd_resolv_headers",
35    export_include_dirs: ["include"],
36}
37
38// Used only by dns_responder_client_ndk.cpp for ResolverStats.h
39// TODO: refactor stats to use a Parcel and eliminate this dependency
40cc_library_headers {
41    name: "libnetd_resolv_internal_headers",
42    export_include_dirs: ["."],
43}
44
45cc_library_headers {
46    name: "dnsproxyd_protocol_headers",
47    sdk_version: "29",
48    min_sdk_version: "29",
49    export_include_dirs: ["include/dnsproxyd_protocol"],
50    apex_available: [
51        "//apex_available:platform",
52        "com.android.tethering",
53    ],
54}
55
56dnsresolver_aidl_interface_lateststable_version = "V10"
57
58cc_library_static {
59    name: "dnsresolver_aidl_interface-lateststable-ndk",
60    whole_static_libs: [
61        "dnsresolver_aidl_interface-" + dnsresolver_aidl_interface_lateststable_version + "-ndk",
62    ],
63    apex_available: [
64        "com.android.resolv",
65    ],
66    min_sdk_version: "29",
67}
68
69aidl_interface {
70    name: "dnsresolver_aidl_interface",
71    local_include_dir: "binder",
72    srcs: [
73        "binder/android/net/IDnsResolver.aidl",
74        "binder/android/net/ResolverHostsParcel.aidl",
75        "binder/android/net/ResolverOptionsParcel.aidl",
76        "binder/android/net/ResolverParamsParcel.aidl",
77        // New AIDL classes should go into android.net.resolv.aidl so they can be clearly identified
78        "binder/android/net/resolv/aidl/**/*.aidl",
79    ],
80    imports: [
81        "netd_event_listener_interface-V1",
82    ],
83    backend: {
84        java: {
85            apex_available: [
86                "com.android.tethering",
87                "com.android.wifi",
88            ],
89            min_sdk_version: "30",
90        },
91        ndk: {
92            gen_log: true,
93            apex_available: [
94                "com.android.resolv",
95            ],
96            min_sdk_version: "29",
97        },
98    },
99    versions: [
100        "1",
101        "2",
102        "3",
103        "4",
104        "5",
105        "6",
106        "7",
107        "8",
108        "9",
109        "10",
110    ],
111    dumpapi: {
112        no_license: true,
113    },
114}
115
116cc_defaults {
117    name: "resolv_test_defaults",
118    cflags: [
119        // networkCreatePhysical and networkCreateVpn were deprecated from netd_aidl_interface v6.
120        "-Wno-error=deprecated-declarations",
121    ],
122    // Note that, static link liblog and libbase is a hard requirement for resolv related tests
123    // because libbase is not compatible between Q and R for general platform build due
124    // to its log revelant functions changing. And most of resolv related tests must be able to run
125    // in Q.
126    static_libs: [
127        "libbase",
128        "liblog",
129    ],
130    // This field is required to make test compatible with Q devices.
131    min_sdk_version: "29",
132}
133
134cc_defaults {
135    // This is necessary to have the coverage tests run on cf_x86_phone.
136    // Because the test_suite target is 64 bit and the test infra is running the 64 bit test
137    // suite on cf_x86_phone (32-bit) for coverage.
138    // See b/147785146 for details.
139    // TODO: Remove this target after coverage test switched to 64-bit device.
140    name: "resolv_test_mts_coverage_defaults",
141    test_config_template: ":resolv_test_config_template",
142    compile_multilib: "both",
143    multilib: {
144        lib32: {
145            suffix: "32",
146        },
147        lib64: {
148            suffix: "64",
149        },
150    },
151}
152
153cc_library {
154    name: "libnetd_resolv",
155    version_script: "libnetd_resolv.map.txt",
156    stubs: {
157        versions: [
158            "1",
159        ],
160        symbol_file: "libnetd_resolv.map.txt",
161    },
162    defaults: ["netd_defaults"],
163    srcs: [
164        "getaddrinfo.cpp",
165        "gethnamaddr.cpp",
166        "sethostent.cpp",
167        "res_cache.cpp",
168        "res_comp.cpp",
169        "res_debug.cpp",
170        "res_mkquery.cpp",
171        "res_query.cpp",
172        "res_send.cpp",
173        "res_stats.cpp",
174        "util.cpp",
175        "Dns64Configuration.cpp",
176        "DnsProxyListener.cpp",
177        "DnsQueryLog.cpp",
178        "DnsResolver.cpp",
179        "DnsResolverService.cpp",
180        "DnsStats.cpp",
181        "DnsTlsDispatcher.cpp",
182        "DnsTlsQueryMap.cpp",
183        "DnsTlsTransport.cpp",
184        "DnsTlsServer.cpp",
185        "DnsTlsSessionCache.cpp",
186        "DnsTlsSocket.cpp",
187        "Experiments.cpp",
188        "PrivateDnsConfiguration.cpp",
189        "ResolverController.cpp",
190        "ResolverEventReporter.cpp",
191    ],
192    // Link most things statically to minimize our dependence on system ABIs.
193    stl: "libc++_static",
194    static_libs: [
195        "dnsresolver_aidl_interface-lateststable-ndk",
196        "libbase",
197        "libcutils",
198        "libnetdutils",
199        "libdoh_ffi",
200        "libmodules-utils-build",
201        "libprotobuf-cpp-lite",
202        "libstatslog_resolv",
203        "libstatspush_compat",
204        "libsysutils",
205        "netd_event_listener_interface-lateststable-ndk",
206        "server_configurable_flags",
207        "stats_proto",
208    ],
209    // libcrypto needs to be used as a shared library because it performs an
210    // integrity check (against a checksum) that is not supported for static
211    // libs. See http://b/141248879
212    // We're also adding libssl here to treat it consistently.
213    // liblog is added as a shared library because it provides stable C API
214    // from the platform; we don't need to include it in this module by
215    // statically linking to it. Doing so is even dangerous because the socket
216    // protocol to logd implemented in the library isn't guaranteed to be
217    // stable. See b/151051671
218    shared_libs: [
219        "libbinder_ndk",
220        "libcrypto",
221        "liblog", //Used by libstatslog_resolv
222        "libssl",
223    ],
224    header_libs: [
225        "libnetdbinder_utils_headers",
226    ],
227    runtime_libs: [
228        // Causes the linkerconfig to create a namespace link from resolv to the
229        // libstatssocket library within the statsd apex
230        "libstatssocket",
231    ],
232    export_include_dirs: ["include"],
233
234    product_variables: {
235        debuggable: {
236            cppflags: [
237                "-DRESOLV_ALLOW_VERBOSE_LOGGING=1",
238            ],
239        },
240    },
241    header_abi_checker: {
242        enabled: true,
243        symbol_file: "libnetd_resolv.map.txt",
244    },
245    sanitize: {
246        cfi: true,
247    },
248    apex_available: ["com.android.resolv"],
249    min_sdk_version: "29",
250}
251
252cc_library_static {
253    name: "stats_proto",
254    defaults: ["netd_defaults"],
255    proto: {
256        export_proto_headers: true,
257        type: "lite",
258    },
259    srcs: [
260        "stats.proto",
261    ],
262    apex_available: ["com.android.resolv"],
263    min_sdk_version: "29",
264}
265
266genrule {
267    name: "statslog_resolv.h",
268    tools: ["stats-log-api-gen"],
269    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_resolv.h --module resolv" +
270        " --namespace android,net,stats --minApiLevel 29",
271    out: [
272        "statslog_resolv.h",
273    ],
274}
275
276genrule {
277    name: "statslog_resolv.cpp",
278    tools: ["stats-log-api-gen"],
279    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_resolv.cpp --module resolv" +
280        " --namespace android,net,stats --importHeader statslog_resolv.h --minApiLevel 29",
281    out: [
282        "statslog_resolv.cpp",
283    ],
284}
285
286cc_library_static {
287    name: "libstatslog_resolv",
288    generated_sources: ["statslog_resolv.cpp"],
289    generated_headers: ["statslog_resolv.h"],
290    defaults: ["netd_defaults"],
291    export_generated_headers: ["statslog_resolv.h"],
292    static_libs: [
293        "libcutils",
294        "libstatspush_compat",
295    ],
296    header_libs: [
297        "libgtest_prod_headers", // Used by libstatspush_compat
298    ],
299    apex_available: ["com.android.resolv"],
300    min_sdk_version: "29",
301}
302
303filegroup {
304    name: "resolv_rust_test_config_template",
305    srcs: [
306        "resolv_rust_test_config_template.xml",
307    ],
308}
309
310filegroup {
311    name: "resolv_test_config_template",
312    srcs: [
313        "resolv_test_config_template.xml",
314    ],
315}
316
317filegroup {
318    name: "resolv_unit_test_files",
319    srcs: [
320        "DnsQueryLogTest.cpp",
321        "DnsStatsTest.cpp",
322        "ExperimentsTest.cpp",
323        "OperationLimiterTest.cpp",
324        "PrivateDnsConfigurationTest.cpp",
325    ],
326}
327
328doh_rust_deps = [
329    "libandroid_logger",
330    "libanyhow",
331    "libbase64_rust",
332    "libfutures",
333    "liblibc",
334    "liblog_rust",
335    "libring",
336    "libthiserror",
337    "libtokio",
338    "liburl",
339]
340
341rust_ffi_static {
342    name: "libdoh_ffi",
343    crate_name: "doh",
344    srcs: ["doh/doh.rs"],
345    edition: "2018",
346
347    rlibs: doh_rust_deps + ["libquiche"],
348    prefer_rlib: true,
349
350    shared_libs: [
351        "libcrypto",
352        "libssl",
353    ],
354
355    apex_available: [
356        "//apex_available:platform", // Needed by doh_ffi_test
357        "com.android.resolv",
358    ],
359    min_sdk_version: "29",
360}
361
362rust_test {
363    name: "doh_unit_test",
364    crate_name: "doh",
365    srcs: ["doh/doh.rs"],
366    edition: "2018",
367    test_suites: ["general-tests"],
368    auto_gen_config: true,
369    // Used to enable root permission for the test.
370    // TODO: remove after 'require_root' is supported in rust_test.
371    test_config_template: ":resolv_rust_test_config_template",
372    rustlibs: doh_rust_deps + ["libquiche_static"],
373    min_sdk_version: "29",
374}
375
376// It's required by unit tests.
377rust_ffi_static {
378    name: "libdoh_ffi_for_test",
379    crate_name: "doh",
380    srcs: ["doh/doh.rs"],
381    edition: "2018",
382
383    rlibs: doh_rust_deps + ["libquiche_static"],
384    prefer_rlib: true,
385    // TODO(b/194022174), for unit tests to run on the Android 10 platform,
386    // libunwind must be statically linked.
387    whole_static_libs: ["libunwind"],
388    apex_available: [
389        "//apex_available:platform", // Needed by doh_ffi_test
390        "com.android.resolv",
391    ],
392    min_sdk_version: "29",
393}
394