aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
blob: 357b58f08412051b5f9dc97117ce236ed9e9c06b (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
//
//  Copyright (c) 2021, The OpenThread Authors.
//  All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//  1. Redistributions of source code must retain the above copyright
//     notice, this list of conditions and the following disclaimer.
//  2. Redistributions in binary form must reproduce the above copyright
//     notice, this list of conditions and the following disclaimer in the
//     documentation and/or other materials provided with the distribution.
//  3. Neither the name of the copyright holder nor the
//     names of its contributors may be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
//  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
//  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
//  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
//  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
//  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
//  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
//  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
//  POSSIBILITY OF SUCH DAMAGE.
//

package {
    default_applicable_licenses: ["external_ot-br-posix_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.
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
// See: http://go/android-license-faq
license {
    name: "external_ot-br-posix_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
        "SPDX-license-identifier-BSD",
        "SPDX-license-identifier-MIT",
    ],
    license_text: [
        "LICENSE",
        "NOTICE",
    ],
}

genrule {
    name: "otbr_version_header",
    cmd: "$(location src/android/config-android-version-gen.sh) < $(in) > $(out)",
    srcs: ["src/android/otbr-config-android-version.h.in"],
    out: ["otbr-config-android-version.h"],
    tool_files: [
        "src/android/config-android-version-gen.sh",
    ],
}

// The config shared by all ot-daemon dependency libraries
cc_defaults {
    name: "ot-daemon-debuggable-cc-defaults",
    cflags: [
        // Optimize for size
        "-Os",

        // Disable exception since OT never uses exceptions
        "-fno-exceptions",
        "-fno-asynchronous-unwind-tables",
        "-fno-unwind-tables",
    ],
    product_variables: {
        debuggable: {
            cflags: [
                // Optimize for debugging
                "-Og",

                // Enable daemon CLI for debugging
                "-DOPENTHREAD_POSIX_CONFIG_DAEMON_CLI_ENABLE=1",
            ]
        }
    },

    // Enable security checks
    sanitize: {
      misc_undefined: ["bounds"],
      cfi: true,
      scs: true,
   },
}

cc_defaults {
    name: "ot-daemon-defaults",
    generated_headers: ["otbr_version_header"],

    include_dirs: [
        "external/mdnsresponder/mDNSShared",
        "external/openthread/include",
        "external/openthread/src",
        "external/openthread/src/posix/platform/include",
        "external/openthread/third_party/mbedtls/repo/include",
    ],

    local_include_dirs: [
        "include",
        "src",
    ],

    cflags: [
        "-Wall",
        "-Wextra",

        // The HAL client implementation requires features which are
        // available on only 31+, but it's guaranteed that ot-daemon
        // will never run on Android U- devices.
        "-Wno-unguarded-availability",

        "-DOTBR_CONFIG_ANDROID_PROPERTY_ENABLE=1",
        "-DOTBR_CONFIG_ANDROID_VERSION_HEADER_ENABLE=1",
        "-DOTBR_CONFIG_FILE=\"src/android/otbr-config-android.h\"",
        "-DOTBR_ENABLE_VENDOR_SERVER=1", // for OtDaemonServer
        "-DOTBR_ENABLE_BORDER_ROUTING=1",
        "-DOTBR_ENABLE_MDNS_MDNSSD=1",
        "-DOTBR_ENABLE_SRP_ADVERTISING_PROXY=1",
        "-DOTBR_ENABLE_DNSSD_DISCOVERY_PROXY=1",
        "-DOTBR_PACKAGE_NAME=\"OTBR_AGENT\"",
    ],

    srcs: [
        "src/agent/application.cpp",
        "src/android/otdaemon_server.cpp",
        "src/android/otdaemon_telemetry.cpp",
        "src/border_agent/border_agent.cpp",
        "src/ncp/ncp_openthread.cpp",
        "src/sdp_proxy/advertising_proxy.cpp",
        "src/sdp_proxy/discovery_proxy.cpp",
        "src/common/code_utils.cpp",
        "src/common/dns_utils.cpp",
        "src/common/logging.cpp",
        "src/common/mainloop.cpp",
        "src/common/mainloop_manager.cpp",
        "src/common/task_runner.cpp",
        "src/common/types.cpp",
        "src/mdns/mdns.cpp",
        "src/mdns/mdns_mdnssd.cpp",
        "src/utils/crc16.cpp",
        "src/utils/dns_utils.cpp",
        "src/utils/hex.cpp",
        "src/utils/infra_link_selector.cpp",
        "src/utils/pskc.cpp",
        "src/utils/socket_utils.cpp",
        "src/utils/steering_data.cpp",
        "src/utils/string_utils.cpp",
        "src/utils/system_utils.cpp",
        "src/utils/thread_helper.cpp",
    ],

    shared_libs: [
        "libbase",
        "libutils",
        "libcutils",
        "libbinder_ndk",
        "android.hardware.threadnetwork-V1-ndk",
        "liblog",
        "libstatssocket",
    ],

    static_libs: [
        "libopenthread-cli",
        "ot-core",
        "ot-daemon-aidl-ndk",
        "libstatslog_threadnetwork",
        "threadnetwork-atom-cc-proto-lite",
        "libprotobuf-cpp-lite",
    ],

    host_ldlibs: ["-lutil"],
    min_sdk_version: "30",
    apex_available: [ "com.android.tethering" ],
}

cc_binary {
    name: "ot-daemon",
    defaults: [
        "ot-daemon-defaults",
        "ot-daemon-debuggable-cc-defaults",
    ],
    srcs: [
        "src/agent/main.cpp",
    ],
}

cc_fuzz {
    name: "ot_daemon_service_fuzzer",
    defaults:[
        "ot-daemon-defaults",
        "service_fuzzer_defaults"
    ],
    srcs: [
        "src/android/otdaemon_fuzzer.cpp",
    ],
    shared_libs: [
        "liblog",
    ],
    fuzz_config: {
        cc: [
            "wgtdkp@google.com",
        ],
    },
}

cc_library_static {
    name: "libstatslog_threadnetwork",
    generated_sources: ["statslog_threadnetwork.cpp"],
    generated_headers: ["statslog_threadnetwork.h"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    export_generated_headers: ["statslog_threadnetwork.h"],
    shared_libs: [
        "libcutils",
        "liblog",
        "libstatssocket",
        "libutils",
    ],
    min_sdk_version: "30",
    apex_available: [ "com.android.tethering" ],
}

genrule {
    name: "statslog_threadnetwork.h",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_threadnetwork.h --module threadnetwork --namespace threadnetwork",
    out: [
        "statslog_threadnetwork.h",
    ],
}

genrule {
    name: "statslog_threadnetwork.cpp",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_threadnetwork.cpp --module threadnetwork --namespace threadnetwork --importHeader statslog_threadnetwork.h",
    out: [
        "statslog_threadnetwork.cpp",
    ],
}