blob: 8e98e9fd5974438acbf7251faddba7d31c74afa7 [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",
Aaron Wisnerdb511202018-06-26 15:38:35 -050079 ],
80
81 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070082 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050083 ],
84
Aaron Wisnerdb511202018-06-26 15:38:35 -050085 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070086 linux: {
87 srcs: ["usb_linux.cpp"],
88 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050089
Dan Willemsenab971b52018-08-29 14:58:02 -070090 darwin: {
91 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050092
Dan Willemsenab971b52018-08-29 14:58:02 -070093 host_ldlibs: [
94 "-framework CoreFoundation",
95 "-framework IOKit",
96 ],
97 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050098
Dan Willemsenab971b52018-08-29 14:58:02 -070099 windows: {
100 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -0500101
Dan Willemsenab971b52018-08-29 14:58:02 -0700102 host_ldlibs: [
103 "-lws2_32",
104 ],
105 },
Aaron Wisnerdb511202018-06-26 15:38:35 -0500106 },
107
108 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -0700109 "-Wall",
110 "-Wextra",
111 "-Werror",
112 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -0500113 ],
114
115 export_include_dirs: ["."],
116
117}
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700118
119cc_defaults {
120 name: "fastboot_defaults",
121
122 cflags: [
123 "-Wall",
124 "-Wextra",
125 "-Werror",
126 "-Wvla",
127 ],
128 rtti: true,
129
130 clang_cflags: [
131 "-Wthread-safety",
132 ],
133}
134
135cc_binary {
136 name: "fastbootd",
137 defaults: ["fastboot_defaults"],
138
139 recovery: true,
140
Yifan Hongb299cb72021-02-17 13:44:49 -0800141 product_variables: {
142 debuggable: {
143 cppflags: ["-DFB_ENABLE_FETCH"],
144 },
145 },
146
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700147 srcs: [
148 "device/commands.cpp",
149 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700150 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700151 "device/main.cpp",
Josh Gao08718242020-03-27 18:09:56 -0700152 "device/usb.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700153 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700154 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700155 "device/utility.cpp",
156 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700157 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700158 ],
159
160 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700161 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700162 "android.hardware.boot@1.1",
josephjang29069752020-09-23 16:28:03 +0800163 "android.hardware.fastboot@1.1",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700164 "android.hardware.health@2.0",
Tao Baob71eedf2018-08-06 19:13:38 -0700165 "libasyncio",
166 "libbase",
167 "libbootloader_message",
168 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700169 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700170 "libext4_utils",
171 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800172 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700173 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700174 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700175 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700176 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700177 "libsparse",
178 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700179 ],
180
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700181 static_libs: [
Hongguang Chen1e239282020-04-22 14:25:45 -0700182 "libgtest_prod",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700183 "libhealthhalutils",
David Andersonaca0bea2020-09-21 16:34:25 -0700184 "libsnapshot_cow",
David Anderson220ddb12019-10-31 18:02:41 -0700185 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700186 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700187 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700188
189 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700190 "avb_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700191 "libsnapshot_headers",
Yifan Honga4eb4752021-02-16 19:37:21 -0800192 "libstorage_literals_headers",
193 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700194}
Dan Willemsenab971b52018-08-29 14:58:02 -0700195
196cc_defaults {
197 name: "fastboot_host_defaults",
198
199 use_version_lib: true,
200
201 cflags: [
202 "-Wall",
203 "-Wextra",
204 "-Werror",
205 "-Wunreachable-code",
206 ],
207
208 target: {
209 darwin: {
210 cflags: ["-Wno-unused-parameter"],
211 host_ldlibs: [
212 "-lpthread",
213 "-framework CoreFoundation",
214 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700215 ],
216 },
217 windows: {
218 enabled: true,
219
220 host_ldlibs: ["-lws2_32"],
221 },
David Anderson89569642018-11-16 15:53:35 -0800222 not_windows: {
223 static_libs: [
224 "libext4_utils",
225 ],
226 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700227 },
228
229 stl: "libc++_static",
230
231 // Don't add anything here, we don't want additional shared dependencies
232 // on the host fastboot tool, and shared libraries that link against libc++
233 // will violate ODR.
234 shared_libs: [],
235
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800236 header_libs: [
237 "avb_headers",
238 "bootimg_headers",
239 ],
240
Dan Willemsenab971b52018-08-29 14:58:02 -0700241 static_libs: [
242 "libziparchive",
243 "libsparse",
244 "libutils",
245 "liblog",
246 "libz",
247 "libdiagnose_usb",
248 "libbase",
249 "libcutils",
250 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800251 "liblp",
252 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700253 ],
254}
255
256//
257// Build host libfastboot.
258//
259
260cc_library_host_static {
261 name: "libfastboot",
262 defaults: ["fastboot_host_defaults"],
263
Dan Willemsenab971b52018-08-29 14:58:02 -0700264 srcs: [
265 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700266 "fastboot.cpp",
267 "fs.cpp",
268 "socket.cpp",
269 "tcp.cpp",
270 "udp.cpp",
271 "util.cpp",
272 "fastboot_driver.cpp",
273 ],
274
275 // Only version the final binaries
276 use_version_lib: false,
277 static_libs: ["libbuildversion"],
278
279 generated_headers: ["platform_tools_version"],
280
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800281 tidy_flags: [
282 // DO NOT add quotes around header-filter flag regex argument,
283 // because build/soong will add quotes around the whole flag.
284 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
285 ],
286
Dan Willemsenab971b52018-08-29 14:58:02 -0700287 target: {
288 windows: {
289 srcs: ["usb_windows.cpp"],
290
291 include_dirs: ["development/host/windows/usb/api"],
292 },
293 darwin: {
294 srcs: ["usb_osx.cpp"],
295 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900296 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700297 srcs: ["usb_linux.cpp"],
298 },
299 },
300}
301
302//
303// Build host fastboot / fastboot.exe
304//
305
306cc_binary_host {
307 name: "fastboot",
308 defaults: ["fastboot_host_defaults"],
309
310 srcs: ["main.cpp"],
311 static_libs: ["libfastboot"],
312
313 required: [
314 "mke2fs",
315 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700316 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700317 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800318 dist: {
319 targets: [
320 "dist_files",
321 "sdk",
322 "win_sdk",
323 ],
324 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700325
326 target: {
327 not_windows: {
328 required: [
329 "e2fsdroid",
330 "mke2fs.conf",
331 "sload_f2fs",
332 ],
333 },
334 windows: {
335 required: ["AdbWinUsbApi"],
336 shared_libs: ["AdbWinApi"],
337 },
338 },
339}
340
341//
342// Build host fastboot_test.
343//
344
345cc_test_host {
346 name: "fastboot_test",
347 defaults: ["fastboot_host_defaults"],
348
349 srcs: [
350 "fastboot_test.cpp",
351 "socket_mock.cpp",
352 "socket_test.cpp",
353 "tcp_test.cpp",
354 "udp_test.cpp",
355 ],
356
357 static_libs: ["libfastboot"],
358
359 target: {
360 windows: {
361 shared_libs: ["AdbWinApi"],
362 },
363 windows_x86_64: {
364 // Avoid trying to build for win64
365 enabled: false,
366 },
367 },
368}