• Home
  • History
  • Annotate
  • 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    ],
167    frozen: true,
168
169}
170
171filegroup {
172    name: "resolv_test_default_map",
173    srcs: ["resolv_test_default.map"],
174}
175
176cc_defaults {
177    name: "resolv_test_defaults",
178    cflags: [
179        // networkCreatePhysical and networkCreateVpn were deprecated from netd_aidl_interface v6.
180        "-Wno-error=deprecated-declarations",
181    ],
182    // The resolv-related tests run on older platform versions, so many libraries (such as
183    // libbase and libc++) need to be linked statically. The tests also need to be linked with a
184    // version script to ensure that the statically-linked library isn't exported from the
185    // executable, where it would override the shared libraries that the platform itself uses. See
186    // b/333438055 for an example of what goes wrong when libc++ is partially exported from an
187    // executable.
188    version_script: ":resolv_test_default_map",
189    stl: "libc++_static",
190    static_libs: [
191        "libbase",
192    ],
193    shared_libs: [
194        "liblog",
195    ],
196    min_sdk_version: "30",
197}
198
199cc_defaults {
200    // This is necessary to have the coverage tests run on cf_x86_phone.
201    // Because the test_suite target is 64 bit and the test infra is running the 64 bit test
202    // suite on cf_x86_phone (32-bit) for coverage.
203    // See b/147785146 for details.
204    // TODO: Remove this target after coverage test switched to 64-bit device.
205    name: "resolv_test_mts_coverage_defaults",
206    test_config_template: ":resolv_test_config_template",
207    compile_multilib: "both",
208    multilib: {
209        lib32: {
210            suffix: "32",
211        },
212        lib64: {
213            suffix: "64",
214        },
215    },
216    // 'resolv_test_config_template' used DisableConfigSyncTargetPreparer provided
217    // by net-tests-utils-host-common; adding it to make the host jar available
218    // after the build process.
219    host_required: [
220        "net-tests-utils-host-common",
221    ],
222}
223
224cc_defaults {
225    // Similar to resolv_test_mts_coverage_defaults, but it's for the tests that don't need
226    // root access.
227    name: "resolv_test_mts_coverage_without_root_defaults",
228    test_config_template: ":resolv_test_config_without_root_template",
229    compile_multilib: "both",
230    multilib: {
231        lib32: {
232            suffix: "32",
233        },
234        lib64: {
235            suffix: "64",
236        },
237    },
238    // 'resolv_test_config_without_root_template' used DisableConfigSyncTargetPreparer
239    // provided by net-tests-utils-host-common; adding it to make the host jar available
240    // after the build process.
241    host_required: [
242        "net-tests-utils-host-common",
243    ],
244}
245
246cc_library {
247    name: "libnetd_resolv",
248    version_script: "libnetd_resolv.map.txt",
249    stubs: {
250        versions: [
251            "1",
252        ],
253        symbol_file: "libnetd_resolv.map.txt",
254    },
255    defaults: ["netd_defaults"],
256    srcs: [
257        "getaddrinfo.cpp",
258        "gethnamaddr.cpp",
259        "sethostent.cpp",
260        "res_cache.cpp",
261        "res_comp.cpp",
262        "res_debug.cpp",
263        "res_mkquery.cpp",
264        "res_query.cpp",
265        "res_send.cpp",
266        "res_stats.cpp",
267        "util.cpp",
268        "Dns64Configuration.cpp",
269        "DnsProxyListener.cpp",
270        "DnsQueryLog.cpp",
271        "DnsResolver.cpp",
272        "DnsResolverService.cpp",
273        "DnsStats.cpp",
274        "DnsTlsDispatcher.cpp",
275        "DnsTlsQueryMap.cpp",
276        "DnsTlsTransport.cpp",
277        "DnsTlsServer.cpp",
278        "DnsTlsSessionCache.cpp",
279        "DnsTlsSocket.cpp",
280        "Experiments.cpp",
281        "PrivateDnsConfiguration.cpp",
282        "ResolverController.cpp",
283        "ResolverEventReporter.cpp",
284    ],
285    // Link most things statically to minimize our dependence on system ABIs.
286    stl: "libc++_static",
287    static_libs: [
288        "dnsresolver_aidl_interface-lateststable-ndk",
289        "libbase",
290        "libcutils",
291        "libnetdutils",
292        "libdoh_ffi",
293        "libmodules-utils-build",
294        "libprotobuf-cpp-lite",
295        "libstatslog_resolv",
296        "libsysutils",
297        "netd_event_listener_interface-lateststable-ndk",
298        "server_configurable_flags",
299        "stats_proto",
300    ],
301    // libcrypto needs to be used as a shared library because it performs an
302    // integrity check (against a checksum) that is not supported for static
303    // libs. See http://b/141248879
304    // We're also adding libssl here to treat it consistently.
305    // liblog is added as a shared library because it provides stable C API
306    // from the platform; we don't need to include it in this module by
307    // statically linking to it. Doing so is even dangerous because the socket
308    // protocol to logd implemented in the library isn't guaranteed to be
309    // stable. See b/151051671
310    shared_libs: [
311        "libbinder_ndk",
312        "libcrypto",
313        "liblog", //Used by libstatslog_resolv
314        "libssl",
315        "libstatssocket",
316    ],
317    runtime_libs: [
318        "libcom.android.tethering.dns_helper",
319    ],
320    header_libs: [
321        "libnetdbinder_utils_headers",
322    ],
323    export_include_dirs: ["include"],
324
325    product_variables: {
326        debuggable: {
327            cppflags: [
328                "-DRESOLV_ALLOW_VERBOSE_LOGGING=1",
329            ],
330        },
331    },
332    header_abi_checker: {
333        enabled: true,
334        symbol_file: "libnetd_resolv.map.txt",
335    },
336    sanitize: {
337        cfi: true,
338    },
339    apex_available: ["com.android.resolv"],
340    min_sdk_version: "30",
341}
342
343cc_library_static {
344    name: "stats_proto",
345    defaults: ["netd_defaults"],
346    proto: {
347        export_proto_headers: true,
348        type: "lite",
349    },
350    srcs: [
351        "stats.proto",
352    ],
353    apex_available: ["com.android.resolv"],
354    min_sdk_version: "30",
355}
356
357genrule {
358    name: "statslog_resolv.h",
359    tools: ["stats-log-api-gen"],
360    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_resolv.h --module resolv" +
361        " --namespace android,net,stats --minApiLevel 30",
362    out: [
363        "statslog_resolv.h",
364    ],
365}
366
367genrule {
368    name: "statslog_resolv.cpp",
369    tools: ["stats-log-api-gen"],
370    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_resolv.cpp --module resolv" +
371        " --namespace android,net,stats --importHeader statslog_resolv.h --minApiLevel 30",
372    out: [
373        "statslog_resolv.cpp",
374    ],
375}
376
377cc_library_static {
378    name: "libstatslog_resolv",
379    generated_sources: ["statslog_resolv.cpp"],
380    generated_headers: ["statslog_resolv.h"],
381    defaults: ["netd_defaults"],
382    export_generated_headers: ["statslog_resolv.h"],
383    static_libs: [
384        "libcutils",
385    ],
386    shared_libs: [
387        "libstatssocket",
388    ],
389    apex_available: ["com.android.resolv"],
390    min_sdk_version: "30",
391}
392
393filegroup {
394    name: "resolv_test_config_template",
395    srcs: [
396        "resolv_test_config_template.xml",
397    ],
398}
399
400filegroup {
401    name: "resolv_test_config_without_root_template",
402    srcs: [
403        "resolv_test_config_without_root_template.xml",
404    ],
405}
406
407filegroup {
408    name: "resolv_unit_test_files",
409    srcs: [
410        "DnsQueryLogTest.cpp",
411        "DnsStatsTest.cpp",
412        "ExperimentsTest.cpp",
413        "OperationLimiterTest.cpp",
414        "PrivateDnsConfigurationTest.cpp",
415    ],
416}
417
418doh_rust_deps = [
419    "libandroid_logger",
420    "libanyhow",
421    "libbase64_rust",
422    "libfutures",
423    "liblibc",
424    "liblog_rust",
425    "libring",
426    "libstatslog_rust",
427    "libthiserror",
428    "libtokio",
429    "liburl",
430]
431
432rust_ffi_static {
433    name: "libdoh_ffi",
434    crate_name: "doh",
435    srcs: ["doh/doh.rs"],
436    edition: "2018",
437
438    rlibs: doh_rust_deps + ["libquiche"],
439    prefer_rlib: true,
440
441    shared_libs: [
442        "libcrypto",
443        "libssl",
444    ],
445
446    apex_available: [
447        "//apex_available:platform", // Needed by doh_ffi_test
448        "com.android.resolv",
449    ],
450    min_sdk_version: "30",
451}
452
453rust_test {
454    name: "doh_unit_test",
455    crate_name: "doh",
456    srcs: ["doh/doh.rs"],
457    edition: "2018",
458    test_suites: ["general-tests"],
459    auto_gen_config: true,
460    rustlibs: doh_rust_deps + ["libquiche_static"],
461    min_sdk_version: "30",
462    shared_libs: ["libc++"],
463}
464
465// It's required by unit tests.
466rust_ffi_static {
467    name: "libdoh_ffi_for_test",
468    crate_name: "doh",
469    srcs: ["doh/doh.rs"],
470    edition: "2018",
471
472    rlibs: doh_rust_deps + ["libquiche_static"],
473    prefer_rlib: true,
474
475    shared_libs: [
476        "libstatssocket",
477    ],
478
479    // TODO(b/194022174), for unit tests to run on the Android 10 platform,
480    // libunwind must be statically linked.
481    whole_static_libs: ["libunwind"],
482    apex_available: [
483        "//apex_available:platform", // Needed by doh_ffi_test
484        "com.android.resolv",
485    ],
486    min_sdk_version: "30",
487}
488
489rust_ffi_static {
490    // Combines libdoh_frontend_ffi and libdoh_ffi for fuzzing test.
491    // Includes multiple static rust libraries will cause duplicate symbol error.
492    name: "libdoh_fuzz_ffi",
493    crate_name: "doh_fuzz_ffi",
494    srcs: [
495        "doh/doh_test_superset_for_fuzzer.rs",
496    ],
497    edition: "2018",
498
499    rlibs: [
500        "libandroid_logger",
501        "libanyhow",
502        "libbase64_rust",
503        "libfutures",
504        "liblazy_static",
505        "liblibc",
506        "liblog_rust",
507        "libquiche_static",
508        "libring",
509        "libstatslog_rust",
510        "libthiserror",
511        "libtokio",
512        "liburl",
513    ],
514
515    whole_static_libs: ["libunwind"],
516}
517