blob: 720810d05d77c9be3f6873f6c05770b690e6208d [file] [log] [blame]
Hridya Valsarajudea91b42018-07-17 11:14:01 -07001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050015// This is required because no Android.bp can include a library defined in an
16// Android.mk. Eventually should kill libfastboot (defined in Android.mk)
Bob Badourd69ad692021-02-16 19:02:14 -080017package {
18 default_applicable_licenses: ["system_core_fastboot_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34// See: http://go/android-license-faq
35license {
36 name: "system_core_fastboot_license",
37 visibility: [":__subpackages__"],
38 license_kinds: [
39 "SPDX-license-identifier-Apache-2.0",
40 "SPDX-license-identifier-BSD",
41 ],
42 // large-scale-change unable to identify any license_text files
43}
44
Aaron Wisnerdb511202018-06-26 15:38:35 -050045cc_library_host_static {
46 name: "libfastboot2",
47
48 //host_supported: true,
49
50 compile_multilib: "first",
51 srcs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070052 "bootimg_utils.cpp",
53 "fs.cpp",
54 "socket.cpp",
55 "tcp.cpp",
56 "udp.cpp",
57 "util.cpp",
58 "fastboot_driver.cpp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050059 ],
60
61 static_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070062 "libziparchive",
63 "libsparse",
64 "libutils",
65 "liblog",
66 "libz",
67 "libdiagnose_usb",
68 "libbase",
69 "libcutils",
70 "libgtest",
71 "libgtest_main",
72 "libbase",
73 "libadb_host",
David Anderson89569642018-11-16 15:53:35 -080074 "liblp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050075 ],
76
77 header_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070078 "bootimg_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -080079 "libstorage_literals_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050080 ],
81
82 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070083 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050084 ],
85
Aaron Wisnerdb511202018-06-26 15:38:35 -050086 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070087 linux: {
88 srcs: ["usb_linux.cpp"],
89 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050090
Dan Willemsenab971b52018-08-29 14:58:02 -070091 darwin: {
92 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050093
Dan Willemsenab971b52018-08-29 14:58:02 -070094 host_ldlibs: [
95 "-framework CoreFoundation",
96 "-framework IOKit",
97 ],
98 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050099
Dan Willemsenab971b52018-08-29 14:58:02 -0700100 windows: {
101 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500102
Dan Willemsenab971b52018-08-29 14:58:02 -0700103 host_ldlibs: [
104 "-lws2_32",
105 ],
106 },
Aaron Wisnerdb511202018-06-26 15:38:35 -0500107 },
108
109 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -0700110 "-Wall",
111 "-Wextra",
112 "-Werror",
113 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -0500114 ],
115
116 export_include_dirs: ["."],
117
118}
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700119
120cc_defaults {
121 name: "fastboot_defaults",
122
123 cflags: [
124 "-Wall",
125 "-Wextra",
126 "-Werror",
127 "-Wvla",
128 ],
129 rtti: true,
130
131 clang_cflags: [
132 "-Wthread-safety",
133 ],
134}
135
136cc_binary {
137 name: "fastbootd",
138 defaults: ["fastboot_defaults"],
139
140 recovery: true,
141
Yifan Hongb299cb72021-02-17 13:44:49 -0800142 product_variables: {
143 debuggable: {
144 cppflags: ["-DFB_ENABLE_FETCH"],
145 },
146 },
147
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700148 srcs: [
149 "device/commands.cpp",
150 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700151 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700152 "device/main.cpp",
Josh Gao08718242020-03-27 18:09:56 -0700153 "device/usb.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700154 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700155 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700156 "device/utility.cpp",
157 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700158 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700159 ],
160
161 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700162 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700163 "android.hardware.boot@1.1",
josephjang29069752020-09-23 16:28:03 +0800164 "android.hardware.fastboot@1.1",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700165 "android.hardware.health@2.0",
Tao Baob71eedf2018-08-06 19:13:38 -0700166 "libasyncio",
167 "libbase",
168 "libbootloader_message",
169 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700170 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700171 "libext4_utils",
172 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800173 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700174 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700175 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700176 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700177 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700178 "libsparse",
179 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700180 ],
181
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700182 static_libs: [
Hongguang Chen1e239282020-04-22 14:25:45 -0700183 "libgtest_prod",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700184 "libhealthhalutils",
David Andersonaca0bea2020-09-21 16:34:25 -0700185 "libsnapshot_cow",
David Anderson220ddb12019-10-31 18:02:41 -0700186 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700187 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700188 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700189
190 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700191 "avb_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700192 "libsnapshot_headers",
Yifan Honga4eb4752021-02-16 19:37:21 -0800193 "libstorage_literals_headers",
194 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700195}
Dan Willemsenab971b52018-08-29 14:58:02 -0700196
197cc_defaults {
198 name: "fastboot_host_defaults",
199
200 use_version_lib: true,
201
202 cflags: [
203 "-Wall",
204 "-Wextra",
205 "-Werror",
206 "-Wunreachable-code",
207 ],
208
209 target: {
210 darwin: {
211 cflags: ["-Wno-unused-parameter"],
212 host_ldlibs: [
213 "-lpthread",
214 "-framework CoreFoundation",
215 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700216 ],
217 },
218 windows: {
219 enabled: true,
220
221 host_ldlibs: ["-lws2_32"],
222 },
David Anderson89569642018-11-16 15:53:35 -0800223 not_windows: {
224 static_libs: [
225 "libext4_utils",
226 ],
227 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700228 },
229
230 stl: "libc++_static",
231
232 // Don't add anything here, we don't want additional shared dependencies
233 // on the host fastboot tool, and shared libraries that link against libc++
234 // will violate ODR.
235 shared_libs: [],
236
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800237 header_libs: [
238 "avb_headers",
239 "bootimg_headers",
240 ],
241
Dan Willemsenab971b52018-08-29 14:58:02 -0700242 static_libs: [
243 "libziparchive",
244 "libsparse",
245 "libutils",
246 "liblog",
247 "libz",
248 "libdiagnose_usb",
249 "libbase",
250 "libcutils",
251 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800252 "liblp",
253 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700254 ],
255}
256
257//
258// Build host libfastboot.
259//
260
261cc_library_host_static {
262 name: "libfastboot",
263 defaults: ["fastboot_host_defaults"],
264
Dan Willemsenab971b52018-08-29 14:58:02 -0700265 srcs: [
266 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700267 "fastboot.cpp",
268 "fs.cpp",
269 "socket.cpp",
270 "tcp.cpp",
271 "udp.cpp",
272 "util.cpp",
273 "fastboot_driver.cpp",
274 ],
275
276 // Only version the final binaries
277 use_version_lib: false,
278 static_libs: ["libbuildversion"],
Yifan Hong17d469b2021-02-18 15:15:46 -0800279 header_libs: [
280 "libstorage_literals_headers",
281 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700282
283 generated_headers: ["platform_tools_version"],
284
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800285 tidy_flags: [
286 // DO NOT add quotes around header-filter flag regex argument,
287 // because build/soong will add quotes around the whole flag.
288 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
289 ],
290
Dan Willemsenab971b52018-08-29 14:58:02 -0700291 target: {
292 windows: {
293 srcs: ["usb_windows.cpp"],
294
295 include_dirs: ["development/host/windows/usb/api"],
296 },
297 darwin: {
298 srcs: ["usb_osx.cpp"],
299 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900300 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700301 srcs: ["usb_linux.cpp"],
302 },
303 },
304}
305
306//
307// Build host fastboot / fastboot.exe
308//
309
310cc_binary_host {
311 name: "fastboot",
312 defaults: ["fastboot_host_defaults"],
313
314 srcs: ["main.cpp"],
315 static_libs: ["libfastboot"],
316
317 required: [
318 "mke2fs",
319 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700320 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700321 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800322 dist: {
323 targets: [
324 "dist_files",
325 "sdk",
326 "win_sdk",
327 ],
328 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700329
330 target: {
331 not_windows: {
332 required: [
333 "e2fsdroid",
334 "mke2fs.conf",
335 "sload_f2fs",
336 ],
337 },
338 windows: {
339 required: ["AdbWinUsbApi"],
340 shared_libs: ["AdbWinApi"],
341 },
342 },
343}
344
345//
346// Build host fastboot_test.
347//
348
349cc_test_host {
350 name: "fastboot_test",
351 defaults: ["fastboot_host_defaults"],
352
353 srcs: [
354 "fastboot_test.cpp",
355 "socket_mock.cpp",
356 "socket_test.cpp",
357 "tcp_test.cpp",
358 "udp_test.cpp",
359 ],
360
361 static_libs: ["libfastboot"],
362
363 target: {
364 windows: {
365 shared_libs: ["AdbWinApi"],
366 },
367 windows_x86_64: {
368 // Avoid trying to build for win64
369 enabled: false,
370 },
371 },
372}