aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
blob: ef98816324c8d25794ac17fb64c84dbf96b9b35d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
package {
    default_applicable_licenses: ["packages_modules_DnsResolver_license"],
}

// Added automatically by a large-scale-change that took the approach of
// 'apply every license found to every target'. While this makes sure we respect
// every license restriction, it may not be entirely correct.
//
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
//
// Please consider splitting the single license below into multiple licenses,
// taking care not to lose any license_kind information, and overriding the
// default license using the 'licenses: [...]' property on targets as needed.
//
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
// to attach the license to, and including a comment whether the files may be
// used in the current project.
// See: http://go/android-license-faq
license {
    name: "packages_modules_DnsResolver_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
        "SPDX-license-identifier-BSD",
        "SPDX-license-identifier-ISC",
        "SPDX-license-identifier-MIT",
    ],
    license_text: [
        "NOTICE",
    ],
}

cc_library_headers {
    name: "libnetd_resolv_headers",
    export_include_dirs: ["include"],
}

// Used only by dns_responder_client_ndk.cpp for ResolverStats.h
// TODO: refactor stats to use a Parcel and eliminate this dependency
cc_library_headers {
    name: "libnetd_resolv_internal_headers",
    export_include_dirs: ["."],
}

cc_library_headers {
    name: "dnsproxyd_protocol_headers",
    sdk_version: "30",
    min_sdk_version: "30",
    export_include_dirs: ["include/dnsproxyd_protocol"],
    apex_available: [
        "//apex_available:platform",
        "com.android.tethering",
    ],
}

dnsresolver_aidl_interface_lateststable_version = "V11"

cc_library_static {
    name: "dnsresolver_aidl_interface-lateststable-ndk",
    whole_static_libs: [
        "dnsresolver_aidl_interface-" + dnsresolver_aidl_interface_lateststable_version + "-ndk",
    ],
    apex_available: [
        "com.android.resolv",
    ],
    min_sdk_version: "30",
}

aidl_interface {
    name: "dnsresolver_aidl_interface",
    local_include_dir: "binder",
    srcs: [
        "binder/android/net/IDnsResolver.aidl",
        "binder/android/net/ResolverHostsParcel.aidl",
        "binder/android/net/ResolverOptionsParcel.aidl",
        "binder/android/net/ResolverParamsParcel.aidl",
        // New AIDL classes should go into android.net.resolv.aidl so they can be clearly identified
        "binder/android/net/resolv/aidl/**/*.aidl",
    ],
    imports: [
        "netd_event_listener_interface-V1",
    ],
    backend: {
        java: {
            apex_available: [
                "com.android.tethering",
                "com.android.wifi",
            ],
            min_sdk_version: "30",
        },
        ndk: {
            gen_log: true,
            apex_available: [
                "com.android.resolv",
            ],
            min_sdk_version: "30",
        },
    },
    versions: [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "10",
        "11",
    ],
    dumpapi: {
        no_license: true,
    },
}

cc_defaults {
    name: "resolv_test_defaults",
    cflags: [
        // networkCreatePhysical and networkCreateVpn were deprecated from netd_aidl_interface v6.
        "-Wno-error=deprecated-declarations",
    ],
    // Note that, static link liblog and libbase is a hard requirement for resolv related tests
    // because libbase is not compatible between Q and R for general platform build due
    // to its log revelant functions changing. And most of resolv related tests must be able to run
    // in Q.
    static_libs: [
        "libbase",
        "liblog",
    ],
    // This field is required to make test compatible with Q devices.
    min_sdk_version: "30",
}

cc_defaults {
    // This is necessary to have the coverage tests run on cf_x86_phone.
    // Because the test_suite target is 64 bit and the test infra is running the 64 bit test
    // suite on cf_x86_phone (32-bit) for coverage.
    // See b/147785146 for details.
    // TODO: Remove this target after coverage test switched to 64-bit device.
    name: "resolv_test_mts_coverage_defaults",
    test_config_template: ":resolv_test_config_template",
    compile_multilib: "both",
    multilib: {
        lib32: {
            suffix: "32",
        },
        lib64: {
            suffix: "64",
        },
    },
    // 'resolv_test_config_template' used DisableConfigSyncTargetPreparer provided
    // by net-tests-utils-host-common; adding it to make the host jar available
    // after the build process.
    host_required: [
        "net-tests-utils-host-common",
    ]
}

cc_defaults {
    // Similar to resolv_test_mts_coverage_defaults, but it's for the tests that don't need
    // root access.
    name: "resolv_test_mts_coverage_without_root_defaults",
    test_config_template: ":resolv_test_config_without_root_template",
    compile_multilib: "both",
    multilib: {
        lib32: {
            suffix: "32",
        },
        lib64: {
            suffix: "64",
        },
    },
    // 'resolv_test_config_without_root_template' used DisableConfigSyncTargetPreparer
    // provided by net-tests-utils-host-common; adding it to make the host jar available
    // after the build process.
    host_required: [
        "net-tests-utils-host-common",
    ]
}

cc_library {
    name: "libnetd_resolv",
    version_script: "libnetd_resolv.map.txt",
    stubs: {
        versions: [
            "1",
        ],
        symbol_file: "libnetd_resolv.map.txt",
    },
    defaults: ["netd_defaults"],
    srcs: [
        "getaddrinfo.cpp",
        "gethnamaddr.cpp",
        "sethostent.cpp",
        "res_cache.cpp",
        "res_comp.cpp",
        "res_debug.cpp",
        "res_mkquery.cpp",
        "res_query.cpp",
        "res_send.cpp",
        "res_stats.cpp",
        "util.cpp",
        "Dns64Configuration.cpp",
        "DnsProxyListener.cpp",
        "DnsQueryLog.cpp",
        "DnsResolver.cpp",
        "DnsResolverService.cpp",
        "DnsStats.cpp",
        "DnsTlsDispatcher.cpp",
        "DnsTlsQueryMap.cpp",
        "DnsTlsTransport.cpp",
        "DnsTlsServer.cpp",
        "DnsTlsSessionCache.cpp",
        "DnsTlsSocket.cpp",
        "Experiments.cpp",
        "PrivateDnsConfiguration.cpp",
        "ResolverController.cpp",
        "ResolverEventReporter.cpp",
    ],
    // Link most things statically to minimize our dependence on system ABIs.
    stl: "libc++_static",
    static_libs: [
        "dnsresolver_aidl_interface-lateststable-ndk",
        "libbase",
        "libcutils",
        "libnetdutils",
        "libdoh_ffi",
        "libmodules-utils-build",
        "libprotobuf-cpp-lite",
        "libstatslog_resolv",
        "libstatspush_compat",
        "libsysutils",
        "netd_event_listener_interface-lateststable-ndk",
        "server_configurable_flags",
        "stats_proto",
    ],
    // libcrypto needs to be used as a shared library because it performs an
    // integrity check (against a checksum) that is not supported for static
    // libs. See http://b/141248879
    // We're also adding libssl here to treat it consistently.
    // liblog is added as a shared library because it provides stable C API
    // from the platform; we don't need to include it in this module by
    // statically linking to it. Doing so is even dangerous because the socket
    // protocol to logd implemented in the library isn't guaranteed to be
    // stable. See b/151051671
    shared_libs: [
        "libbinder_ndk",
        "libcrypto",
        "liblog", //Used by libstatslog_resolv
        "libssl",
        "libstatssocket",
    ],
    header_libs: [
        "libnetdbinder_utils_headers",
    ],
    export_include_dirs: ["include"],

    product_variables: {
        debuggable: {
            cppflags: [
                "-DRESOLV_ALLOW_VERBOSE_LOGGING=1",
            ],
        },
    },
    header_abi_checker: {
        enabled: true,
        symbol_file: "libnetd_resolv.map.txt",
    },
    sanitize: {
        cfi: true,
    },
    apex_available: ["com.android.resolv"],
    min_sdk_version: "30",
}

cc_library_static {
    name: "stats_proto",
    defaults: ["netd_defaults"],
    proto: {
        export_proto_headers: true,
        type: "lite",
    },
    srcs: [
        "stats.proto",
    ],
    apex_available: ["com.android.resolv"],
    min_sdk_version: "30",
}

genrule {
    name: "statslog_resolv.h",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_resolv.h --module resolv" +
        " --namespace android,net,stats --minApiLevel 29",
    out: [
        "statslog_resolv.h",
    ],
}

genrule {
    name: "statslog_resolv.cpp",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_resolv.cpp --module resolv" +
        " --namespace android,net,stats --importHeader statslog_resolv.h --minApiLevel 29",
    out: [
        "statslog_resolv.cpp",
    ],
}

cc_library_static {
    name: "libstatslog_resolv",
    generated_sources: ["statslog_resolv.cpp"],
    generated_headers: ["statslog_resolv.h"],
    defaults: ["netd_defaults"],
    export_generated_headers: ["statslog_resolv.h"],
    static_libs: [
        "libcutils",
        "libstatspush_compat",
    ],
    header_libs: [
        "libgtest_prod_headers", // Used by libstatspush_compat
    ],
    apex_available: ["com.android.resolv"],
    min_sdk_version: "30",
}

filegroup {
    name: "resolv_test_config_template",
    srcs: [
        "resolv_test_config_template.xml",
    ],
}

filegroup {
    name: "resolv_test_config_without_root_template",
    srcs: [
        "resolv_test_config_without_root_template.xml",
    ],
}

filegroup {
    name: "resolv_unit_test_files",
    srcs: [
        "DnsQueryLogTest.cpp",
        "DnsStatsTest.cpp",
        "ExperimentsTest.cpp",
        "OperationLimiterTest.cpp",
        "PrivateDnsConfigurationTest.cpp",
    ],
}

doh_rust_deps = [
    "libandroid_logger",
    "libanyhow",
    "libbase64_rust",
    "libfutures",
    "liblibc",
    "liblog_rust",
    "libring",
    "libstatslog_rust",
    "libthiserror",
    "libtokio",
    "liburl",
]

rust_ffi_static {
    name: "libdoh_ffi",
    crate_name: "doh",
    srcs: ["doh/doh.rs"],
    edition: "2018",

    rlibs: doh_rust_deps + ["libquiche"],
    prefer_rlib: true,

    shared_libs: [
        "libcrypto",
        "libssl",
    ],

    apex_available: [
        "//apex_available:platform", // Needed by doh_ffi_test
        "com.android.resolv",
    ],
    min_sdk_version: "30",
}

rust_test {
    name: "doh_unit_test",
    crate_name: "doh",
    srcs: ["doh/doh.rs"],
    edition: "2018",
    test_suites: ["general-tests"],
    auto_gen_config: true,
    rustlibs: doh_rust_deps + ["libquiche_static"],
    min_sdk_version: "30",
}

// It's required by unit tests.
rust_ffi_static {
    name: "libdoh_ffi_for_test",
    crate_name: "doh",
    srcs: ["doh/doh.rs"],
    edition: "2018",

    rlibs: doh_rust_deps + ["libquiche_static"],
    prefer_rlib: true,

    shared_libs: [
        "libstatssocket",
    ],

    // TODO(b/194022174), for unit tests to run on the Android 10 platform,
    // libunwind must be statically linked.
    whole_static_libs: ["libunwind"],
    apex_available: [
        "//apex_available:platform", // Needed by doh_ffi_test
        "com.android.resolv",
    ],
    min_sdk_version: "30",
}

rust_ffi_static {
    // Combines libdoh_frontend_ffi and libdoh_ffi for fuzzing test.
    // Includes multiple static rust libraries will cause duplicate symbol error.
    name: "libdoh_fuzz_ffi",
    crate_name: "doh_fuzz_ffi",
    srcs: [
        "doh/doh_test_superset_for_fuzzer.rs",
    ],
    edition: "2018",

    rlibs: [
        "libandroid_logger",
        "libanyhow",
        "libbase64_rust",
        "libfutures",
        "liblazy_static",
        "liblibc",
        "liblog_rust",
        "libquiche_static",
        "libring",
        "libstatslog_rust",
        "libthiserror",
        "libtokio",
        "liburl",
    ],

    whole_static_libs: ["libunwind"],
}