blob: 1a91d1e39ddcaa180f5c7869a142d222a401c914 [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
141 srcs: [
142 "device/commands.cpp",
143 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700144 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700145 "device/main.cpp",
Josh Gao08718242020-03-27 18:09:56 -0700146 "device/usb.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700147 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700148 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700149 "device/utility.cpp",
150 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700151 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700152 ],
153
154 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700155 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700156 "android.hardware.boot@1.1",
josephjang29069752020-09-23 16:28:03 +0800157 "android.hardware.fastboot@1.1",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700158 "android.hardware.health@2.0",
Tao Baob71eedf2018-08-06 19:13:38 -0700159 "libasyncio",
160 "libbase",
161 "libbootloader_message",
162 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700163 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700164 "libext4_utils",
165 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800166 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700167 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700168 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700169 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700170 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700171 "libsparse",
172 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700173 ],
174
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700175 static_libs: [
Hongguang Chen1e239282020-04-22 14:25:45 -0700176 "libgtest_prod",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700177 "libhealthhalutils",
David Andersonaca0bea2020-09-21 16:34:25 -0700178 "libsnapshot_cow",
David Anderson220ddb12019-10-31 18:02:41 -0700179 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700180 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700181 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700182
183 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700184 "avb_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700185 "libsnapshot_headers",
186 ]
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700187}
Dan Willemsenab971b52018-08-29 14:58:02 -0700188
189cc_defaults {
190 name: "fastboot_host_defaults",
191
192 use_version_lib: true,
193
194 cflags: [
195 "-Wall",
196 "-Wextra",
197 "-Werror",
198 "-Wunreachable-code",
199 ],
200
201 target: {
202 darwin: {
203 cflags: ["-Wno-unused-parameter"],
204 host_ldlibs: [
205 "-lpthread",
206 "-framework CoreFoundation",
207 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700208 ],
209 },
210 windows: {
211 enabled: true,
212
213 host_ldlibs: ["-lws2_32"],
214 },
David Anderson89569642018-11-16 15:53:35 -0800215 not_windows: {
216 static_libs: [
217 "libext4_utils",
218 ],
219 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700220 },
221
222 stl: "libc++_static",
223
224 // Don't add anything here, we don't want additional shared dependencies
225 // on the host fastboot tool, and shared libraries that link against libc++
226 // will violate ODR.
227 shared_libs: [],
228
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800229 header_libs: [
230 "avb_headers",
231 "bootimg_headers",
232 ],
233
Dan Willemsenab971b52018-08-29 14:58:02 -0700234 static_libs: [
235 "libziparchive",
236 "libsparse",
237 "libutils",
238 "liblog",
239 "libz",
240 "libdiagnose_usb",
241 "libbase",
242 "libcutils",
243 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800244 "liblp",
245 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700246 ],
247}
248
249//
250// Build host libfastboot.
251//
252
253cc_library_host_static {
254 name: "libfastboot",
255 defaults: ["fastboot_host_defaults"],
256
Dan Willemsenab971b52018-08-29 14:58:02 -0700257 srcs: [
258 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700259 "fastboot.cpp",
260 "fs.cpp",
261 "socket.cpp",
262 "tcp.cpp",
263 "udp.cpp",
264 "util.cpp",
265 "fastboot_driver.cpp",
266 ],
267
268 // Only version the final binaries
269 use_version_lib: false,
270 static_libs: ["libbuildversion"],
271
272 generated_headers: ["platform_tools_version"],
273
274 target: {
275 windows: {
276 srcs: ["usb_windows.cpp"],
277
278 include_dirs: ["development/host/windows/usb/api"],
279 },
280 darwin: {
281 srcs: ["usb_osx.cpp"],
282 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900283 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700284 srcs: ["usb_linux.cpp"],
285 },
286 },
287}
288
289//
290// Build host fastboot / fastboot.exe
291//
292
293cc_binary_host {
294 name: "fastboot",
295 defaults: ["fastboot_host_defaults"],
296
297 srcs: ["main.cpp"],
298 static_libs: ["libfastboot"],
299
300 required: [
301 "mke2fs",
302 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700303 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700304 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800305 dist: {
306 targets: [
307 "dist_files",
308 "sdk",
309 "win_sdk",
310 ],
311 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700312
313 target: {
314 not_windows: {
315 required: [
316 "e2fsdroid",
317 "mke2fs.conf",
318 "sload_f2fs",
319 ],
320 },
321 windows: {
322 required: ["AdbWinUsbApi"],
323 shared_libs: ["AdbWinApi"],
324 },
325 },
326}
327
328//
329// Build host fastboot_test.
330//
331
332cc_test_host {
333 name: "fastboot_test",
334 defaults: ["fastboot_host_defaults"],
335
336 srcs: [
337 "fastboot_test.cpp",
338 "socket_mock.cpp",
339 "socket_test.cpp",
340 "tcp_test.cpp",
341 "udp_test.cpp",
342 ],
343
344 static_libs: ["libfastboot"],
345
346 target: {
347 windows: {
348 shared_libs: ["AdbWinApi"],
349 },
350 windows_x86_64: {
351 // Avoid trying to build for win64
352 enabled: false,
353 },
354 },
355}