• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_team: "trendy_team_fwk_core_networking",
3    default_applicable_licenses: ["packages_modules_DnsResolver_license"],
4}
5
6// Added automatically by a large-scale-change that took the approach of
7// 'apply every license found to every target'. While this makes sure we respect
8// every license restriction, it may not be entirely correct.
9//
10// e.g. GPL in an MIT project might only apply to the contrib/ directory.
11//
12// Please consider splitting the single license below into multiple licenses,
13// taking care not to lose any license_kind information, and overriding the
14// default license using the 'licenses: [...]' property on targets as needed.
15//
16// For unused files, consider creating a 'fileGroup' with "//visibility:private"
17// to attach the license to, and including a comment whether the files may be
18// used in the current project.
19// See: http://go/android-license-faq
20license {
21    name: "packages_modules_DnsResolver_license",
22    visibility: [":__subpackages__"],
23    license_kinds: [
24        "SPDX-license-identifier-Apache-2.0",
25        "SPDX-license-identifier-BSD",
26        "SPDX-license-identifier-ISC",
27        "SPDX-license-identifier-MIT",
28    ],
29    license_text: [
30        "NOTICE",
31    ],
32}
33
34cc_library_headers {
35    name: "libnetd_resolv_headers",
36    export_include_dirs: ["include"],
37}
38
39// Used only by dns_responder_client_ndk.cpp for ResolverStats.h
40// TODO: refactor stats to use a Parcel and eliminate this dependency
41cc_library_headers {
42    name: "libnetd_resolv_internal_headers",
43    export_include_dirs: ["."],
44}
45
46cc_library_headers {
47    name: "dnsproxyd_protocol_headers",
48    sdk_version: "30",
49    min_sdk_version: "30",
50    export_include_dirs: ["include/dnsproxyd_protocol"],
51    apex_available: [
52        "//apex_available:platform",
53        "com.android.tethering",
54    ],
55}
56
57dnsresolver_aidl_interface_lateststable_version = "V15"
58
59cc_library_static {
60    name: "dnsresolver_aidl_interface-lateststable-ndk",
61    whole_static_libs: [
62        "dnsresolver_aidl_interface-" + dnsresolver_aidl_interface_lateststable_version + "-ndk",
63    ],
64    apex_available: [
65        "com.android.resolv",
66    ],
67    min_sdk_version: "30",
68}
69
70aidl_interface {
71    name: "dnsresolver_aidl_interface",
72    local_include_dir: "binder",
73    srcs: [
74        "binder/android/net/IDnsResolver.aidl",
75        "binder/android/net/ResolverHostsParcel.aidl",
76        "binder/android/net/ResolverOptionsParcel.aidl",
77        "binder/android/net/ResolverParamsParcel.aidl",
78        // New AIDL classes should go into android.net.resolv.aidl so they can be clearly identified
79        "binder/android/net/resolv/aidl/**/*.aidl",
80    ],
81    imports: [
82        "netd_event_listener_interface-V1",
83    ],
84    backend: {
85        java: {
86            apex_available: [
87                "com.android.tethering",
88                "com.android.wifi",
89            ],
90            min_sdk_version: "30",
91        },
92        ndk: {
93            gen_log: true,
94            apex_available: [
95                "com.android.resolv",
96            ],
97            min_sdk_version: "30",
98        },
99    },
100
101    dumpapi: {
102        no_license: true,
103    },
104    versions_with_info: [
105        {
106            version: "1",
107            imports: ["netd_event_listener_interface-V1"],
108        },
109        {
110            version: "2",
111            imports: ["netd_event_listener_interface-V1"],
112        },
113        {
114            version: "3",
115            imports: ["netd_event_listener_interface-V1"],
116        },
117        {
118            version: "4",
119            imports: ["netd_event_listener_interface-V1"],
120        },
121        {
122            version: "5",
123            imports: ["netd_event_listener_interface-V1"],
124        },
125        {
126            version: "6",
127            imports: ["netd_event_listener_interface-V1"],
128        },
129        {
130            version: "7",
131            imports: ["netd_event_listener_interface-V1"],
132        },
133        {
134            version: "8",
135            imports: ["netd_event_listener_interface-V1"],
136        },
137        {
138            version: "9",
139            imports: ["netd_event_listener_interface-V1"],
140        },
141        {
142            version: "10",
143            imports: ["netd_event_listener_interface-V1"],
144        },
145        {
146            version: "11",
147            imports: ["netd_event_listener_interface-V1"],
148        },
149        {
150            version: "12",
151            imports: ["netd_event_listener_interface-V1"],
152        },
153        {
154            version: "13",
155            imports: ["netd_event_listener_interface-V1"],
156        },
157        {
158            version: "14",
159            imports: ["netd_event_listener_interface-V1"],
160        },
161        {
162            version: "15",
163            imports: ["netd_event_listener_interface-V1"],
164        },
165        {
166            version: "16",
167            imports: ["netd_event_listener_interface-V1"],
168        },
169
170    ],
171    frozen: true,
172
173}
174
175filegroup {
176    name: "resolv_test_default_map",
177    srcs: ["resolv_test_default.map"],
178}
179
180cc_defaults {
181    name: "resolv_test_defaults",
182    cflags: [
183        // networkCreatePhysical and networkCreateVpn were deprecated from netd_aidl_interface v6.
184        "-Wno-error=deprecated-declarations",
185    ],
186    // The resolv-related tests run on older platform versions, so many libraries (such as
187    // libbase and libc++) need to be linked statically. The tests also need to be linked with a
188    // version script to ensure that the statically-linked library isn't exported from the
189    // executable, where it would override the shared libraries that the platform itself uses. See
190    // b/333438055 for an example of what goes wrong when libc++ is partially exported from an
191    // executable.
192    version_script: ":resolv_test_default_map",
193    stl: "libc++_static",
194    static_libs: [
195        "libbase",
196    ],
197    shared_libs: [
198        "liblog",
199    ],
200    min_sdk_version: "30",
201}
202
203cc_defaults {
204    // This is necessary to have the coverage tests run on cf_x86_phone.
205    // Because the test_suite target is 64 bit and the test infra is running the 64 bit test
206    // suite on cf_x86_phone (32-bit) for coverage.
207    // See b/147785146 for details.
208    // TODO: Remove this target after coverage test switched to 64-bit device.
209    name: "resolv_test_mts_coverage_defaults",
210    test_config_template: ":resolv_test_config_template",
211    compile_multilib: "both",
212    multilib: {
213        lib32: {
214            suffix: "32",
215        },
216        lib64: {
217            suffix: "64",
218        },
219    },
220    // 'resolv_test_config_template' used DisableConfigSyncTargetPreparer provided
221    // by net-tests-utils-host-common; adding it to make the host jar available
222    // after the build process.
223    host_required: [
224        "net-tests-utils-host-common",
225    ],
226}
227
228cc_defaults {
229    // Similar to resolv_test_mts_coverage_defaults, but it's for the tests that don't need
230    // root access.
231    name: "resolv_test_mts_coverage_without_root_defaults",
232    test_config_template: ":resolv_test_config_without_root_template",
233    compile_multilib: "both",
234    multilib: {
235        lib32: {
236            suffix: "32",
237        },
238        lib64: {
239            suffix: "64",
240        },
241    },
242    // 'resolv_test_config_without_root_template' used DisableConfigSyncTargetPreparer
243    // provided by net-tests-utils-host-common; adding it to make the host jar available
244    // after the build process.
245    host_required: [
246        "net-tests-utils-host-common",
247    ],
248}
249
250cc_library {
251    name: "libnetd_resolv",
252    version_script: "libnetd_resolv.map.txt",
253    stubs: {
254        versions: [
255            "1",
256        ],
257        symbol_file: "libnetd_resolv.map.txt",
258    },
259    defaults: ["netd_defaults"],
260    srcs: [
261        "getaddrinfo.cpp",
262        "gethnamaddr.cpp",
263        "sethostent.cpp",
264        "res_cache.cpp",
265        "res_comp.cpp",
266        "res_debug.cpp",
267        "res_mkquery.cpp",
268        "res_query.cpp",
269        "res_send.cpp",
270        "res_stats.cpp",
271        "util.cpp",
272        "Dns64Configuration.cpp",
273        "DnsProxyListener.cpp",
274        "DnsQueryLog.cpp",
275        "DnsResolver.cpp",
276        "DnsResolverService.cpp",
277        "DnsStats.cpp",
278        "DnsTlsDispatcher.cpp",
279        "DnsTlsQueryMap.cpp",
280        "DnsTlsTransport.cpp",
281        "DnsTlsServer.cpp",
282        "DnsTlsSessionCache.cpp",
283        "DnsTlsSocket.cpp",
284        "Experiments.cpp",
285        "PrivateDnsConfiguration.cpp",
286        "ResolverController.cpp",
287        "ResolverEventReporter.cpp",
288    ],
289    // Link most things statically to minimize our dependence on system ABIs.
290    stl: "libc++_static",
291    static_libs: [
292        "dnsresolver_aidl_interface-lateststable-ndk",
293        "libbase",
294        "libcutils",
295        "libnetdutils",
296        "libdoh_ffi",
297        "libmodules-utils-build",
298        "libprotobuf-cpp-lite",
299        "libstatslog_resolv",
300        "libsysutils",
301        "netd_event_listener_interface-lateststable-ndk",
302        "server_configurable_flags",
303        "stats_proto",
304    ],
305    // libcrypto needs to be used as a shared library because it performs an
306    // integrity check (against a checksum) that is not supported for static
307    // libs. See http://b/141248879
308    // We're also adding libssl here to treat it consistently.
309    // liblog is added as a shared library because it provides stable C API
310    // from the platform; we don't need to include it in this module by
311    // statically linking to it. Doing so is even dangerous because the socket
312    // protocol to logd implemented in the library isn't guaranteed to be
313    // stable. See b/151051671
314    shared_libs: [
315        "libbinder_ndk",
316        "libcrypto",
317        "liblog", //Used by libstatslog_resolv
318        "libssl",
319        "libstatssocket",
320    ],
321    runtime_libs: [
322        "libcom.android.tethering.dns_helper",
323    ],
324    header_libs: [
325        "libnetdbinder_utils_headers",
326    ],
327    export_include_dirs: ["include"],
328
329    product_variables: {
330        debuggable: {
331            cppflags: [
332                "-DRESOLV_ALLOW_VERBOSE_LOGGING=1",
333            ],
334        },
335    },
336    header_abi_checker: {
337        enabled: true,
338        symbol_file: "libnetd_resolv.map.txt",
339    },
340    sanitize: {
341        cfi: true,
342    },
343    apex_available: ["com.android.resolv"],
344    min_sdk_version: "30",
345}
346
347cc_library_static {
348    name: "stats_proto",
349    defaults: ["netd_defaults"],
350    proto: {
351        export_proto_headers: true,
352        type: "lite",
353    },
354    srcs: [
355        "stats.proto",
356    ],
357    apex_available: ["com.android.resolv"],
358    min_sdk_version: "30",
359}
360
361genrule {
362    name: "statslog_resolv.h",
363    tools: ["stats-log-api-gen"],
364    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_resolv.h --module resolv" +
365        " --namespace android,net,stats --minApiLevel 30",
366    out: [
367        "statslog_resolv.h",
368    ],
369}
370
371genrule {
372    name: "statslog_resolv.cpp",
373    tools: ["stats-log-api-gen"],
374    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_resolv.cpp --module resolv" +
375        " --namespace android,net,stats --importHeader statslog_resolv.h --minApiLevel 30",
376    out: [
377        "statslog_resolv.cpp",
378    ],
379}
380
381cc_library_static {
382    name: "libstatslog_resolv",
383    generated_sources: ["statslog_resolv.cpp"],
384    generated_headers: ["statslog_resolv.h"],
385    defaults: ["netd_defaults"],
386    export_generated_headers: ["statslog_resolv.h"],
387    static_libs: [
388        "libcutils",
389    ],
390    shared_libs: [
391        "libstatssocket",
392    ],
393    apex_available: ["com.android.resolv"],
394    min_sdk_version: "30",
395}
396
397filegroup {
398    name: "resolv_test_config_template",
399    srcs: [
400        "resolv_test_config_template.xml",
401    ],
402}
403
404filegroup {
405    name: "resolv_test_config_without_root_template",
406    srcs: [
407        "resolv_test_config_without_root_template.xml",
408    ],
409}
410
411filegroup {
412    name: "resolv_unit_test_files",
413    srcs: [
414        "DnsQueryLogTest.cpp",
415        "DnsStatsTest.cpp",
416        "ExperimentsTest.cpp",
417        "OperationLimiterTest.cpp",
418        "PrivateDnsConfigurationTest.cpp",
419    ],
420}
421
422doh_rust_deps = [
423    "libandroid_logger",
424    "libanyhow",
425    "libbase64_rust",
426    "libfutures",
427    "liblibc",
428    "liblog_rust",
429    "libring",
430    "libstatslog_dns_resolver_rust",
431    "libthiserror",
432    "libtokio",
433    "liburl",
434]
435
436rust_ffi_static {
437    name: "libdoh_ffi",
438    crate_name: "doh",
439    srcs: ["doh/doh.rs"],
440    edition: "2018",
441
442    rlibs: doh_rust_deps + ["libquiche"],
443    prefer_rlib: true,
444
445    shared_libs: [
446        "libcrypto",
447        "libssl",
448    ],
449
450    apex_available: [
451        "//apex_available:platform", // Needed by doh_ffi_test
452        "com.android.resolv",
453    ],
454    min_sdk_version: "30",
455}
456
457rust_test {
458    name: "doh_unit_test",
459    crate_name: "doh",
460    srcs: ["doh/doh.rs"],
461    edition: "2018",
462    test_suites: ["general-tests"],
463    auto_gen_config: true,
464    rustlibs: doh_rust_deps + ["libquiche_static"],
465    min_sdk_version: "30",
466    shared_libs: ["libc++"],
467}
468
469// It's required by unit tests.
470rust_ffi_static {
471    name: "libdoh_ffi_for_test",
472    crate_name: "doh",
473    srcs: ["doh/doh.rs"],
474    edition: "2018",
475
476    rlibs: doh_rust_deps + ["libquiche_static"],
477    prefer_rlib: true,
478
479    shared_libs: [
480        "libstatssocket",
481    ],
482
483    // TODO(b/194022174), for unit tests to run on the Android 10 platform,
484    // libunwind must be statically linked.
485    whole_static_libs: ["libunwind"],
486    apex_available: [
487        "//apex_available:platform", // Needed by doh_ffi_test
488        "com.android.resolv",
489    ],
490    min_sdk_version: "30",
491}
492
493rust_ffi_static {
494    // Combines libdoh_frontend_ffi and libdoh_ffi for fuzzing test.
495    // Includes multiple static rust libraries will cause duplicate symbol error.
496    name: "libdoh_fuzz_ffi",
497    crate_name: "doh_fuzz_ffi",
498    srcs: [
499        "doh/doh_test_superset_for_fuzzer.rs",
500    ],
501    edition: "2018",
502
503    rlibs: [
504        "libandroid_logger",
505        "libanyhow",
506        "libbase64_rust",
507        "libfutures",
508        "liblibc",
509        "liblog_rust",
510        "libquiche_static",
511        "libring",
512        "libstatslog_dns_resolver_rust",
513        "libthiserror",
514        "libtokio",
515        "liburl",
516    ],
517
518    whole_static_libs: ["libunwind"],
519}
520