xref: /aosp_15_r20/external/mdnsresponder/Android.bp (revision 48a54d368dc4fa860885eef7b70b6c53499e7c25)
1package {
2    default_applicable_licenses: ["external_mdnsresponder_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: "external_mdnsresponder_license",
21    visibility: [":__subpackages__"],
22    license_kinds: [
23        "SPDX-license-identifier-Apache-2.0",
24        "SPDX-license-identifier-BSD",
25        "SPDX-license-identifier-NCSA",
26        "SPDX-license-identifier-OpenSSL",
27        "legacy_notice",
28    ],
29    license_text: [
30        "LICENSE",
31    ],
32}
33
34cc_defaults {
35    name: "mdnsresponder_default_cflags",
36
37    // This code has a variety of C23 issues,
38    // and is likely to be removed soon anyway.
39    c_std: "gnu17",
40    cflags: [
41        "-O2",
42        "-g",
43        "-fno-strict-aliasing",
44        "-fwrapv",
45        "-D_GNU_SOURCE",
46        "-DHAVE_IPV6",
47        "-DNOT_HAVE_SA_LEN",
48        "-DPLATFORM_NO_RLIMIT",
49        "-DMDNS_DEBUGMSGS=0",
50        "-DMDNS_UDS_SERVERPATH=\"/dev/socket/mdnsd\"",
51        "-DMDNS_USERNAME=\"mdnsr\"",
52        "-W",
53        "-Wall",
54        "-Wextra",
55        "-Wno-address-of-packed-member",
56        "-Wno-array-bounds",
57        "-Wno-pointer-sign",
58        "-Wno-unused",
59        "-Wno-unused-but-set-variable",
60        "-Wno-unused-parameter",
61        "-Werror=implicit-function-declaration",
62    ],
63    target: {
64        linux: {
65            cflags: [
66                "-DTARGET_OS_LINUX",
67                "-DHAVE_LINUX",
68                "-DUSES_NETLINK",
69                "-Werror",
70            ],
71        },
72        darwin: {
73            cflags: [
74                "-DTARGET_OS_MAC",
75                "-DMDNS_UDS_SERVERPATH=\"/var/run/mDNSResponder\"",
76                "-Wno-error",
77            ],
78        },
79        windows: {
80            enabled: true,
81            cflags: [
82                "-DTARGET_OS_WINDOWS",
83                "-DWIN32",
84                "-DNDEBUG",
85                "-D_WIN32_LEAN_AND_MEAN",
86                "-DUSE_TCP_LOOPBACK",
87                "-D_CRT_SECURE_NO_DEPRECATE",
88                "-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1",
89                "-Wno-error",
90                "-Wno-sign-compare",
91                "-include stdint.h",
92                "-include winsock2.h",
93                "-include ws2ipdef.h",
94                "-include wincrypt.h",
95                "-include netioapi.h",
96            ],
97            local_include_dirs: [
98                "mDNSWindows",
99                "android/caseMapping",
100            ],
101        },
102    },
103}
104
105cc_binary {
106    name: "mdnsd",
107    defaults: ["mdnsresponder_default_cflags"],
108    srcs: [
109        "mDNSCore/DNSCommon.c",
110        "mDNSCore/DNSDigest.c",
111        "mDNSCore/mDNS.c",
112        "mDNSCore/uDNS.c",
113        "mDNSPosix/mDNSPosix.c",
114        "mDNSPosix/mDNSUNP.c",
115        "mDNSPosix/PosixDaemon.c",
116        "mDNSShared/dnssd_ipc.c",
117        "mDNSShared/GenLinkedList.c",
118        "mDNSShared/mDNSDebug.c",
119        "mDNSShared/PlatformCommon.c",
120        "mDNSShared/uds_daemon.c",
121    ],
122
123    local_include_dirs: [
124        "mDNSCore",
125        "mDNSPosix",
126        "mDNSShared",
127    ],
128    init_rc: ["mdnsd.rc"],
129
130    cflags: ["-DMDNS_VERSIONSTR_NODTS=1"],
131
132    shared_libs: [
133        "libcutils",
134        "liblog",
135    ],
136}
137
138//#########################
139
140cc_library {
141    name: "libmdnssd",
142    defaults: ["mdnsresponder_default_cflags"],
143    host_supported: true,
144    recovery_available: true,
145    srcs: [
146        "mDNSShared/dnssd_clientlib.c",
147        "mDNSShared/dnssd_clientstub.c",
148        "mDNSShared/dnssd_ipc.c",
149    ],
150
151    target: {
152        host: {
153            shared: {
154                enabled: false,
155            },
156        },
157        windows: {
158            srcs: ["mDNSWindows/DLL/dllmain.c"],
159
160            cflags: [
161                "-D_WINDOWS",
162                "-D_USERDLL",
163                "-D_MDNS_DEBUGMSGS=0",
164                "-D_SSIZE_T",
165                "-DNOT_HAVE_SA_LENGTH",
166                "-Wno-unknown-pragmas",
167                "-Wno-overflow",
168                "-Wno-pragma-pack",
169                "-include iphlpapi.h",
170                "-include stdlib.h",
171                "-include stdio.h",
172            ],
173        },
174    },
175
176    export_include_dirs: ["mDNSShared"],
177
178    static_libs: ["libcutils"],
179    shared_libs: ["liblog"],
180
181    min_sdk_version: "apex_inherit",
182    apex_available: [
183        "//apex_available:platform",
184        "com.android.adbd",
185    ],
186    visibility: [
187        "//bootable/recovery/minadbd:__subpackages__",
188        "//packages/modules/adb:__subpackages__",
189    ],
190}
191