blob: 7794c4b464fd402bb9b814e845fe9dbdab1e3906 [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 {
Hridya Valsaraju99373792022-01-18 13:58:46 -080018 default_applicable_licenses: [
19 "system_core_fastboot_license",
20 "Android-Apache-2.0",
21 ],
Bob Badourd69ad692021-02-16 19:02:14 -080022}
23
24// Added automatically by a large-scale-change that took the approach of
25// 'apply every license found to every target'. While this makes sure we respect
26// every license restriction, it may not be entirely correct.
27//
28// e.g. GPL in an MIT project might only apply to the contrib/ directory.
29//
30// Please consider splitting the single license below into multiple licenses,
31// taking care not to lose any license_kind information, and overriding the
32// default license using the 'licenses: [...]' property on targets as needed.
33//
34// For unused files, consider creating a 'fileGroup' with "//visibility:private"
35// to attach the license to, and including a comment whether the files may be
36// used in the current project.
37// See: http://go/android-license-faq
38license {
39 name: "system_core_fastboot_license",
40 visibility: [":__subpackages__"],
41 license_kinds: [
Bob Badourd69ad692021-02-16 19:02:14 -080042 "SPDX-license-identifier-BSD",
43 ],
Hridya Valsaraju99373792022-01-18 13:58:46 -080044 license_text: ["LICENSE"],
Bob Badourd69ad692021-02-16 19:02:14 -080045}
46
Aaron Wisnerdb511202018-06-26 15:38:35 -050047cc_library_host_static {
48 name: "libfastboot2",
49
50 //host_supported: true,
51
52 compile_multilib: "first",
53 srcs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070054 "bootimg_utils.cpp",
55 "fs.cpp",
56 "socket.cpp",
57 "tcp.cpp",
58 "udp.cpp",
59 "util.cpp",
Yifan Honge71fe242021-02-22 15:00:15 -080060 "vendor_boot_img_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -070061 "fastboot_driver.cpp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050062 ],
63
64 static_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070065 "libziparchive",
66 "libsparse",
67 "libutils",
68 "liblog",
69 "libz",
70 "libdiagnose_usb",
71 "libbase",
72 "libcutils",
73 "libgtest",
74 "libgtest_main",
75 "libbase",
76 "libadb_host",
David Anderson89569642018-11-16 15:53:35 -080077 "liblp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050078 ],
79
80 header_libs: [
Yifan Honge71fe242021-02-22 15:00:15 -080081 "avb_headers",
Dan Willemsenab971b52018-08-29 14:58:02 -070082 "bootimg_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -080083 "libstorage_literals_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050084 ],
85
86 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070087 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050088 ],
89
Aaron Wisnerdb511202018-06-26 15:38:35 -050090 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070091 linux: {
92 srcs: ["usb_linux.cpp"],
93 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050094
Dan Willemsenab971b52018-08-29 14:58:02 -070095 darwin: {
96 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050097
Dan Willemsenab971b52018-08-29 14:58:02 -070098 host_ldlibs: [
99 "-framework CoreFoundation",
100 "-framework IOKit",
101 ],
102 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500103
Dan Willemsenab971b52018-08-29 14:58:02 -0700104 windows: {
105 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500106
Dan Willemsenab971b52018-08-29 14:58:02 -0700107 host_ldlibs: [
108 "-lws2_32",
109 ],
110 },
Aaron Wisnerdb511202018-06-26 15:38:35 -0500111 },
112
113 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -0700114 "-Wall",
115 "-Wextra",
116 "-Werror",
117 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -0500118 ],
119
120 export_include_dirs: ["."],
121
122}
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700123
124cc_defaults {
125 name: "fastboot_defaults",
126
127 cflags: [
128 "-Wall",
129 "-Wextra",
130 "-Werror",
131 "-Wvla",
Yifan Hong07e947f2021-03-22 19:21:34 -0700132 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Alix96403392022-04-21 03:03:27 +0000133 "-Wthread-safety",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700134 ],
135 rtti: true,
136
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700137}
138
139cc_binary {
140 name: "fastbootd",
141 defaults: ["fastboot_defaults"],
142
143 recovery: true,
144
Yifan Hongb299cb72021-02-17 13:44:49 -0800145 product_variables: {
146 debuggable: {
147 cppflags: ["-DFB_ENABLE_FETCH"],
148 },
149 },
150
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700151 srcs: [
152 "device/commands.cpp",
153 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700154 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700155 "device/main.cpp",
Josh Gao08718242020-03-27 18:09:56 -0700156 "device/usb.cpp",
Kelvin Zhang682e5b52022-07-12 17:37:54 -0700157 "device/usb_iouring.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700158 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700159 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700160 "device/utility.cpp",
161 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700162 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700163 ],
164
165 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700166 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700167 "android.hardware.boot@1.1",
Kelvin Zhang6befe782022-06-21 14:20:54 -0700168 "android.hardware.boot-V1-ndk",
169 "libboot_control_client",
josephjang29069752020-09-23 16:28:03 +0800170 "android.hardware.fastboot@1.1",
Sandeep Dhavale2534d482022-11-08 22:30:05 +0000171 "android.hardware.fastboot-V1-ndk",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700172 "android.hardware.health@2.0",
Jack Wu06357942022-11-30 12:46:08 +0800173 "android.hardware.health-V2-ndk",
Tao Baob71eedf2018-08-06 19:13:38 -0700174 "libasyncio",
175 "libbase",
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800176 "libbinder_ndk",
Tao Baob71eedf2018-08-06 19:13:38 -0700177 "libbootloader_message",
178 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700179 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700180 "libext4_utils",
181 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800182 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700183 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700184 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700185 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700186 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700187 "libsparse",
188 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700189 ],
190
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700191 static_libs: [
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800192 "android.hardware.health-translate-ndk",
David Anderson0b903f92021-04-07 21:43:03 -0700193 "libc++fs",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700194 "libhealthhalutils",
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800195 "libhealthshim",
Sandeep Dhavale2534d482022-11-08 22:30:05 +0000196 "libfastbootshim",
David Andersonaca0bea2020-09-21 16:34:25 -0700197 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700198 "liblz4",
David Anderson220ddb12019-10-31 18:02:41 -0700199 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700200 "update_metadata-protos",
Kelvin Zhang682e5b52022-07-12 17:37:54 -0700201 "liburing",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700202 ],
Kelvin Zhang682e5b52022-07-12 17:37:54 -0700203 include_dirs: ["bionic/libc/kernel"],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700204
205 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700206 "avb_headers",
Elliott Hughes02a83242021-04-20 15:22:02 -0700207 "libgtest_prod_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700208 "libsnapshot_headers",
Yifan Honga4eb4752021-02-16 19:37:21 -0800209 "libstorage_literals_headers",
210 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700211}
Dan Willemsenab971b52018-08-29 14:58:02 -0700212
213cc_defaults {
214 name: "fastboot_host_defaults",
215
216 use_version_lib: true,
217
218 cflags: [
219 "-Wall",
220 "-Wextra",
221 "-Werror",
222 "-Wunreachable-code",
Yifan Hong58532df2021-03-22 16:39:13 -0700223 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Alix96403392022-04-21 03:03:27 +0000224 "-D_FILE_OFFSET_BITS=64",
Dan Willemsenab971b52018-08-29 14:58:02 -0700225 ],
226
227 target: {
228 darwin: {
229 cflags: ["-Wno-unused-parameter"],
230 host_ldlibs: [
231 "-lpthread",
232 "-framework CoreFoundation",
233 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700234 ],
235 },
236 windows: {
237 enabled: true,
238
239 host_ldlibs: ["-lws2_32"],
240 },
David Anderson89569642018-11-16 15:53:35 -0800241 not_windows: {
242 static_libs: [
243 "libext4_utils",
244 ],
245 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700246 },
247
248 stl: "libc++_static",
249
250 // Don't add anything here, we don't want additional shared dependencies
251 // on the host fastboot tool, and shared libraries that link against libc++
252 // will violate ODR.
253 shared_libs: [],
254
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800255 header_libs: [
256 "avb_headers",
257 "bootimg_headers",
258 ],
259
Dan Willemsenab971b52018-08-29 14:58:02 -0700260 static_libs: [
261 "libziparchive",
262 "libsparse",
263 "libutils",
264 "liblog",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700265 "liblz4",
Dan Willemsenab971b52018-08-29 14:58:02 -0700266 "libz",
267 "libdiagnose_usb",
268 "libbase",
269 "libcutils",
270 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800271 "liblp",
272 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700273 ],
274}
275
276//
277// Build host libfastboot.
278//
279
280cc_library_host_static {
281 name: "libfastboot",
282 defaults: ["fastboot_host_defaults"],
283
Dan Willemsenab971b52018-08-29 14:58:02 -0700284 srcs: [
285 "bootimg_utils.cpp",
Dmitrii Merkurev91297172023-02-09 02:08:14 +0000286 "fastboot_driver.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700287 "fastboot.cpp",
Dmitrii Merkurev91297172023-02-09 02:08:14 +0000288 "filesystem.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700289 "fs.cpp",
290 "socket.cpp",
Dmitrii Merkurev91297172023-02-09 02:08:14 +0000291 "storage.cpp",
David Anderson667b1ef2023-01-27 21:11:11 -0800292 "super_flash_helper.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700293 "tcp.cpp",
294 "udp.cpp",
295 "util.cpp",
Yifan Honge71fe242021-02-22 15:00:15 -0800296 "vendor_boot_img_utils.cpp",
Daniel Zheng0d307182023-01-31 21:07:53 +0000297 "task.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700298 ],
299
300 // Only version the final binaries
301 use_version_lib: false,
302 static_libs: ["libbuildversion"],
Yifan Hong17d469b2021-02-18 15:15:46 -0800303 header_libs: [
Yifan Honge71fe242021-02-22 15:00:15 -0800304 "avb_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -0800305 "libstorage_literals_headers",
306 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700307
308 generated_headers: ["platform_tools_version"],
309
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800310 tidy_flags: [
311 // DO NOT add quotes around header-filter flag regex argument,
312 // because build/soong will add quotes around the whole flag.
313 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
314 ],
315
Dan Willemsenab971b52018-08-29 14:58:02 -0700316 target: {
317 windows: {
318 srcs: ["usb_windows.cpp"],
319
320 include_dirs: ["development/host/windows/usb/api"],
321 },
322 darwin: {
323 srcs: ["usb_osx.cpp"],
324 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900325 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700326 srcs: ["usb_linux.cpp"],
327 },
328 },
329}
330
331//
332// Build host fastboot / fastboot.exe
333//
334
335cc_binary_host {
336 name: "fastboot",
337 defaults: ["fastboot_host_defaults"],
338
339 srcs: ["main.cpp"],
340 static_libs: ["libfastboot"],
341
342 required: [
343 "mke2fs",
344 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700345 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700346 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800347 dist: {
348 targets: [
349 "dist_files",
350 "sdk",
Shaju Mathew6c27f232022-10-06 22:12:10 +0000351 "sdk-repo-platform-tools",
352 "sdk_repo",
Dan Willemsen3f439a72018-11-19 19:11:35 -0800353 "win_sdk",
354 ],
355 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700356
357 target: {
358 not_windows: {
359 required: [
Dan Willemsenab971b52018-08-29 14:58:02 -0700360 "mke2fs.conf",
Dan Willemsenab971b52018-08-29 14:58:02 -0700361 ],
362 },
363 windows: {
364 required: ["AdbWinUsbApi"],
365 shared_libs: ["AdbWinApi"],
366 },
367 },
368}
369
370//
371// Build host fastboot_test.
372//
373
374cc_test_host {
375 name: "fastboot_test",
376 defaults: ["fastboot_host_defaults"],
377
378 srcs: [
David Andersone6d8dd32023-02-13 14:09:16 -0800379 "fastboot_driver_test.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700380 "fastboot_test.cpp",
381 "socket_mock.cpp",
382 "socket_test.cpp",
David Andersonada87182023-02-08 22:06:56 -0800383 "super_flash_helper_test.cpp",
Daniel Zheng76aa2572023-03-30 15:48:23 -0700384 "task_test.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700385 "tcp_test.cpp",
386 "udp_test.cpp",
387 ],
388
David Andersone6d8dd32023-02-13 14:09:16 -0800389 static_libs: [
390 "libfastboot",
391 "libgmock",
392 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700393
394 target: {
395 windows: {
396 shared_libs: ["AdbWinApi"],
397 },
398 windows_x86_64: {
399 // Avoid trying to build for win64
400 enabled: false,
401 },
402 },
David Anderson86e869a2023-02-08 13:58:40 -0800403
404 test_suites: ["general-tests"],
David Andersonada87182023-02-08 22:06:56 -0800405
406 data: [
407 "testdata/super.img",
408 "testdata/super_empty.img",
409 "testdata/system.img",
410 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700411}
Yifan Honge71fe242021-02-22 15:00:15 -0800412
413cc_test_host {
414 name: "fastboot_vendor_boot_img_utils_test",
415 srcs: ["vendor_boot_img_utils_test.cpp"],
416 static_libs: [
417 "libbase",
418 "libc++fs",
419 "libfastboot",
420 "libgmock",
421 "liblog",
422 ],
423 header_libs: [
424 "avb_headers",
425 "bootimg_headers",
426 ],
427 cflags: [
428 "-Wall",
429 "-Werror",
430 ],
431 data: [
432 ":fastboot_test_dtb",
433 ":fastboot_test_bootconfig",
434 ":fastboot_test_vendor_ramdisk_none",
435 ":fastboot_test_vendor_ramdisk_platform",
436 ":fastboot_test_vendor_ramdisk_replace",
437 ":fastboot_test_vendor_boot_v3",
438 ":fastboot_test_vendor_boot_v4_without_frag",
Alix96403392022-04-21 03:03:27 +0000439 ":fastboot_test_vendor_boot_v4_with_frag",
Yifan Honge71fe242021-02-22 15:00:15 -0800440 ],
441}
Ayushi Khopkarce5c0332021-09-20 12:00:21 +0530442
443cc_library_headers {
444 name: "fastboot_headers",
445 host_supported: true,
446 export_include_dirs: ["."],
447}