blob: bf9ec90bc92acb3296f60aae7b54faff238cf0b0 [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",
Yifan Honge71fe242021-02-22 15:00:15 -080058 "vendor_boot_img_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -070059 "fastboot_driver.cpp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050060 ],
61
62 static_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070063 "libziparchive",
64 "libsparse",
65 "libutils",
66 "liblog",
67 "libz",
68 "libdiagnose_usb",
69 "libbase",
70 "libcutils",
71 "libgtest",
72 "libgtest_main",
73 "libbase",
74 "libadb_host",
David Anderson89569642018-11-16 15:53:35 -080075 "liblp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050076 ],
77
78 header_libs: [
Yifan Honge71fe242021-02-22 15:00:15 -080079 "avb_headers",
Dan Willemsenab971b52018-08-29 14:58:02 -070080 "bootimg_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -080081 "libstorage_literals_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050082 ],
83
84 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070085 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050086 ],
87
Aaron Wisnerdb511202018-06-26 15:38:35 -050088 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070089 linux: {
90 srcs: ["usb_linux.cpp"],
91 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050092
Dan Willemsenab971b52018-08-29 14:58:02 -070093 darwin: {
94 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050095
Dan Willemsenab971b52018-08-29 14:58:02 -070096 host_ldlibs: [
97 "-framework CoreFoundation",
98 "-framework IOKit",
99 ],
100 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500101
Dan Willemsenab971b52018-08-29 14:58:02 -0700102 windows: {
103 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500104
Dan Willemsenab971b52018-08-29 14:58:02 -0700105 host_ldlibs: [
106 "-lws2_32",
107 ],
108 },
Aaron Wisnerdb511202018-06-26 15:38:35 -0500109 },
110
111 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -0700112 "-Wall",
113 "-Wextra",
114 "-Werror",
115 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -0500116 ],
117
118 export_include_dirs: ["."],
119
120}
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700121
122cc_defaults {
123 name: "fastboot_defaults",
124
125 cflags: [
126 "-Wall",
127 "-Wextra",
128 "-Werror",
129 "-Wvla",
Yifan Hong07e947f2021-03-22 19:21:34 -0700130 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700131 ],
132 rtti: true,
133
134 clang_cflags: [
135 "-Wthread-safety",
136 ],
137}
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",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700157 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700158 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700159 "device/utility.cpp",
160 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700161 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700162 ],
163
164 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700165 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700166 "android.hardware.boot@1.1",
josephjang29069752020-09-23 16:28:03 +0800167 "android.hardware.fastboot@1.1",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700168 "android.hardware.health@2.0",
Tao Baob71eedf2018-08-06 19:13:38 -0700169 "libasyncio",
170 "libbase",
171 "libbootloader_message",
172 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700173 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700174 "libext4_utils",
175 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800176 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700177 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700178 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700179 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700180 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700181 "libsparse",
182 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700183 ],
184
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700185 static_libs: [
Hongguang Chen1e239282020-04-22 14:25:45 -0700186 "libgtest_prod",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700187 "libhealthhalutils",
David Andersonaca0bea2020-09-21 16:34:25 -0700188 "libsnapshot_cow",
David Anderson220ddb12019-10-31 18:02:41 -0700189 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700190 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700191 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700192
193 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700194 "avb_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700195 "libsnapshot_headers",
Yifan Honga4eb4752021-02-16 19:37:21 -0800196 "libstorage_literals_headers",
197 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700198}
Dan Willemsenab971b52018-08-29 14:58:02 -0700199
200cc_defaults {
201 name: "fastboot_host_defaults",
202
203 use_version_lib: true,
204
205 cflags: [
206 "-Wall",
207 "-Wextra",
208 "-Werror",
209 "-Wunreachable-code",
Yifan Hong58532df2021-03-22 16:39:13 -0700210 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Dan Willemsenab971b52018-08-29 14:58:02 -0700211 ],
212
213 target: {
214 darwin: {
215 cflags: ["-Wno-unused-parameter"],
216 host_ldlibs: [
217 "-lpthread",
218 "-framework CoreFoundation",
219 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700220 ],
221 },
222 windows: {
223 enabled: true,
224
225 host_ldlibs: ["-lws2_32"],
226 },
David Anderson89569642018-11-16 15:53:35 -0800227 not_windows: {
228 static_libs: [
229 "libext4_utils",
230 ],
231 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700232 },
233
234 stl: "libc++_static",
235
236 // Don't add anything here, we don't want additional shared dependencies
237 // on the host fastboot tool, and shared libraries that link against libc++
238 // will violate ODR.
239 shared_libs: [],
240
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800241 header_libs: [
242 "avb_headers",
243 "bootimg_headers",
244 ],
245
Dan Willemsenab971b52018-08-29 14:58:02 -0700246 static_libs: [
247 "libziparchive",
248 "libsparse",
249 "libutils",
250 "liblog",
251 "libz",
252 "libdiagnose_usb",
253 "libbase",
254 "libcutils",
255 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800256 "liblp",
257 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700258 ],
259}
260
261//
262// Build host libfastboot.
263//
264
265cc_library_host_static {
266 name: "libfastboot",
267 defaults: ["fastboot_host_defaults"],
268
Dan Willemsenab971b52018-08-29 14:58:02 -0700269 srcs: [
270 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700271 "fastboot.cpp",
272 "fs.cpp",
273 "socket.cpp",
274 "tcp.cpp",
275 "udp.cpp",
276 "util.cpp",
Yifan Honge71fe242021-02-22 15:00:15 -0800277 "vendor_boot_img_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700278 "fastboot_driver.cpp",
279 ],
280
281 // Only version the final binaries
282 use_version_lib: false,
283 static_libs: ["libbuildversion"],
Yifan Hong17d469b2021-02-18 15:15:46 -0800284 header_libs: [
Yifan Honge71fe242021-02-22 15:00:15 -0800285 "avb_headers",
Yifan Hong17d469b2021-02-18 15:15:46 -0800286 "libstorage_literals_headers",
287 ],
Dan Willemsenab971b52018-08-29 14:58:02 -0700288
289 generated_headers: ["platform_tools_version"],
290
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800291 tidy_flags: [
292 // DO NOT add quotes around header-filter flag regex argument,
293 // because build/soong will add quotes around the whole flag.
294 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
295 ],
296
Dan Willemsenab971b52018-08-29 14:58:02 -0700297 target: {
298 windows: {
299 srcs: ["usb_windows.cpp"],
300
301 include_dirs: ["development/host/windows/usb/api"],
302 },
303 darwin: {
304 srcs: ["usb_osx.cpp"],
305 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900306 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700307 srcs: ["usb_linux.cpp"],
308 },
309 },
310}
311
312//
313// Build host fastboot / fastboot.exe
314//
315
316cc_binary_host {
317 name: "fastboot",
318 defaults: ["fastboot_host_defaults"],
319
320 srcs: ["main.cpp"],
321 static_libs: ["libfastboot"],
322
323 required: [
324 "mke2fs",
325 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700326 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700327 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800328 dist: {
329 targets: [
330 "dist_files",
331 "sdk",
332 "win_sdk",
333 ],
334 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700335
336 target: {
337 not_windows: {
338 required: [
339 "e2fsdroid",
340 "mke2fs.conf",
341 "sload_f2fs",
342 ],
343 },
344 windows: {
345 required: ["AdbWinUsbApi"],
346 shared_libs: ["AdbWinApi"],
347 },
348 },
349}
350
351//
352// Build host fastboot_test.
353//
354
355cc_test_host {
356 name: "fastboot_test",
357 defaults: ["fastboot_host_defaults"],
358
359 srcs: [
360 "fastboot_test.cpp",
361 "socket_mock.cpp",
362 "socket_test.cpp",
363 "tcp_test.cpp",
364 "udp_test.cpp",
365 ],
366
367 static_libs: ["libfastboot"],
368
369 target: {
370 windows: {
371 shared_libs: ["AdbWinApi"],
372 },
373 windows_x86_64: {
374 // Avoid trying to build for win64
375 enabled: false,
376 },
377 },
378}
Yifan Honge71fe242021-02-22 15:00:15 -0800379
380cc_test_host {
381 name: "fastboot_vendor_boot_img_utils_test",
382 srcs: ["vendor_boot_img_utils_test.cpp"],
383 static_libs: [
384 "libbase",
385 "libc++fs",
386 "libfastboot",
387 "libgmock",
388 "liblog",
389 ],
390 header_libs: [
391 "avb_headers",
392 "bootimg_headers",
393 ],
394 cflags: [
395 "-Wall",
396 "-Werror",
397 ],
398 data: [
399 ":fastboot_test_dtb",
400 ":fastboot_test_bootconfig",
401 ":fastboot_test_vendor_ramdisk_none",
402 ":fastboot_test_vendor_ramdisk_platform",
403 ":fastboot_test_vendor_ramdisk_replace",
404 ":fastboot_test_vendor_boot_v3",
405 ":fastboot_test_vendor_boot_v4_without_frag",
406 ":fastboot_test_vendor_boot_v4_with_frag"
407 ],
408}