blob: 9ae2c3782119de7500a09ae72022064d38406502 [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",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700133 ],
134 rtti: true,
135
136 clang_cflags: [
137 "-Wthread-safety",
138 ],
139}
140
141cc_binary {
142 name: "fastbootd",
143 defaults: ["fastboot_defaults"],
144
145 recovery: true,
146
Yifan Hongb299cb72021-02-17 13:44:49 -0800147 product_variables: {
148 debuggable: {
149 cppflags: ["-DFB_ENABLE_FETCH"],
150 },
151 },
152
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700153 srcs: [
154 "device/commands.cpp",
155 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700156 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700157 "device/main.cpp",
Josh Gao08718242020-03-27 18:09:56 -0700158 "device/usb.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700159 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700160 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700161 "device/utility.cpp",
162 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700163 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700164 ],
165
166 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700167 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700168 "android.hardware.boot@1.1",
josephjang29069752020-09-23 16:28:03 +0800169 "android.hardware.fastboot@1.1",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700170 "android.hardware.health@2.0",
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800171 "android.hardware.health-V1-ndk",
Tao Baob71eedf2018-08-06 19:13:38 -0700172 "libasyncio",
173 "libbase",
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800174 "libbinder_ndk",
Tao Baob71eedf2018-08-06 19:13:38 -0700175 "libbootloader_message",
176 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700177 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700178 "libext4_utils",
179 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800180 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700181 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700182 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700183 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700184 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700185 "libsparse",
186 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700187 ],
188
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700189 static_libs: [
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800190 "android.hardware.health-translate-ndk",
David Anderson0b903f92021-04-07 21:43:03 -0700191 "libc++fs",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700192 "libhealthhalutils",
Yifan Hong4cb88dc2021-12-02 18:58:02 -0800193 "libhealthshim",
David Andersonaca0bea2020-09-21 16:34:25 -0700194 "libsnapshot_cow",
David Anderson220ddb12019-10-31 18:02:41 -0700195 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700196 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700197 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700198
199 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700200 "avb_headers",
Elliott Hughes02a83242021-04-20 15:22:02 -0700201 "libgtest_prod_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700202 "libsnapshot_headers",
Yifan Honga4eb4752021-02-16 19:37:21 -0800203 "libstorage_literals_headers",
204 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700205}
Dan Willemsenab971b52018-08-29 14:58:02 -0700206
207cc_defaults {
208 name: "fastboot_host_defaults",
209
210 use_version_lib: true,
211
212 cflags: [
213 "-Wall",
214 "-Wextra",
215 "-Werror",
216 "-Wunreachable-code",
Yifan Hong58532df2021-03-22 16:39:13 -0700217 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Yifan Hongc8715002021-03-23 10:27:01 -0700218 "-D_FILE_OFFSET_BITS=64"
Dan Willemsenab971b52018-08-29 14:58:02 -0700219 ],
220
221 target: {
222 darwin: {
223 cflags: ["-Wno-unused-parameter"],
224 host_ldlibs: [
225 "-lpthread",
226 "-framework CoreFoundation",
227 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700228 ],
229 },
230 windows: {
231 enabled: true,
232
233 host_ldlibs: ["-lws2_32"],
234 },
David Anderson89569642018-11-16 15:53:35 -0800235 not_windows: {
236 static_libs: [
237 "libext4_utils",
238 ],
239 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700240 },
241
242 stl: "libc++_static",
243
244 // Don't add anything here, we don't want additional shared dependencies
245 // on the host fastboot tool, and shared libraries that link against libc++
246 // will violate ODR.
247 shared_libs: [],
248
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800249 header_libs: [
250 "avb_headers",
251 "bootimg_headers",
252 ],
253
Dan Willemsenab971b52018-08-29 14:58:02 -0700254 static_libs: [
255 "libziparchive",
256 "libsparse",
257 "libutils",
258 "liblog",
259 "libz",
260 "libdiagnose_usb",
261 "libbase",
262 "libcutils",
263 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800264 "liblp",
265 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700266 ],
267}
268
269//
270// Build host libfastboot.
271//
272
273cc_library_host_static {
274 name: "libfastboot",
275 defaults: ["fastboot_host_defaults"],
276
Dan Willemsenab971b52018-08-29 14:58:02 -0700277 srcs: [
278 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700279 "fastboot.cpp",
280 "fs.cpp",
281 "socket.cpp",
282 "tcp.cpp",
283 "udp.cpp",
284 "util.cpp",
Yifan Honge71fe242021-02-22 15:00:15 -0800285 "vendor_boot_img_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700286 "fastboot_driver.cpp",
287 ],
288
289 // Only version the final binaries
290 use_version_lib: false,
291 static_libs: ["libbuildversion"],
Yifan Hong17d469b2021-02-18 15:15:46 -0800292 header_libs: [
Yifan Honge71fe242021-02-22 15:00:15 -0800293 "avb_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -0800294 "libstorage_literals_headers",
295 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700296
297 generated_headers: ["platform_tools_version"],
298
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800299 tidy_flags: [
300 // DO NOT add quotes around header-filter flag regex argument,
301 // because build/soong will add quotes around the whole flag.
302 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
303 ],
304
Dan Willemsenab971b52018-08-29 14:58:02 -0700305 target: {
306 windows: {
307 srcs: ["usb_windows.cpp"],
308
309 include_dirs: ["development/host/windows/usb/api"],
310 },
311 darwin: {
312 srcs: ["usb_osx.cpp"],
313 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900314 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700315 srcs: ["usb_linux.cpp"],
316 },
317 },
318}
319
320//
321// Build host fastboot / fastboot.exe
322//
323
324cc_binary_host {
325 name: "fastboot",
326 defaults: ["fastboot_host_defaults"],
327
328 srcs: ["main.cpp"],
329 static_libs: ["libfastboot"],
330
331 required: [
332 "mke2fs",
333 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700334 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700335 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800336 dist: {
337 targets: [
338 "dist_files",
339 "sdk",
340 "win_sdk",
341 ],
342 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700343
344 target: {
345 not_windows: {
346 required: [
347 "e2fsdroid",
348 "mke2fs.conf",
349 "sload_f2fs",
350 ],
351 },
352 windows: {
353 required: ["AdbWinUsbApi"],
354 shared_libs: ["AdbWinApi"],
355 },
356 },
357}
358
359//
360// Build host fastboot_test.
361//
362
363cc_test_host {
364 name: "fastboot_test",
365 defaults: ["fastboot_host_defaults"],
366
367 srcs: [
368 "fastboot_test.cpp",
369 "socket_mock.cpp",
370 "socket_test.cpp",
371 "tcp_test.cpp",
372 "udp_test.cpp",
373 ],
374
375 static_libs: ["libfastboot"],
376
377 target: {
378 windows: {
379 shared_libs: ["AdbWinApi"],
380 },
381 windows_x86_64: {
382 // Avoid trying to build for win64
383 enabled: false,
384 },
385 },
386}
Yifan Honge71fe242021-02-22 15:00:15 -0800387
388cc_test_host {
389 name: "fastboot_vendor_boot_img_utils_test",
390 srcs: ["vendor_boot_img_utils_test.cpp"],
391 static_libs: [
392 "libbase",
393 "libc++fs",
394 "libfastboot",
395 "libgmock",
396 "liblog",
397 ],
398 header_libs: [
399 "avb_headers",
400 "bootimg_headers",
401 ],
402 cflags: [
403 "-Wall",
404 "-Werror",
405 ],
406 data: [
407 ":fastboot_test_dtb",
408 ":fastboot_test_bootconfig",
409 ":fastboot_test_vendor_ramdisk_none",
410 ":fastboot_test_vendor_ramdisk_platform",
411 ":fastboot_test_vendor_ramdisk_replace",
412 ":fastboot_test_vendor_boot_v3",
413 ":fastboot_test_vendor_boot_v4_without_frag",
414 ":fastboot_test_vendor_boot_v4_with_frag"
415 ],
416}
Ayushi Khopkarce5c0332021-09-20 12:00:21 +0530417
418cc_library_headers {
419 name: "fastboot_headers",
420 host_supported: true,
421 export_include_dirs: ["."],
422}