blob: daff496d94905e623b862818b0f0d1c053dc33d0 [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",
192 ]
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700193}
Dan Willemsenab971b52018-08-29 14:58:02 -0700194
195cc_defaults {
196 name: "fastboot_host_defaults",
197
198 use_version_lib: true,
199
200 cflags: [
201 "-Wall",
202 "-Wextra",
203 "-Werror",
204 "-Wunreachable-code",
205 ],
206
207 target: {
208 darwin: {
209 cflags: ["-Wno-unused-parameter"],
210 host_ldlibs: [
211 "-lpthread",
212 "-framework CoreFoundation",
213 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700214 ],
215 },
216 windows: {
217 enabled: true,
218
219 host_ldlibs: ["-lws2_32"],
220 },
David Anderson89569642018-11-16 15:53:35 -0800221 not_windows: {
222 static_libs: [
223 "libext4_utils",
224 ],
225 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700226 },
227
228 stl: "libc++_static",
229
230 // Don't add anything here, we don't want additional shared dependencies
231 // on the host fastboot tool, and shared libraries that link against libc++
232 // will violate ODR.
233 shared_libs: [],
234
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800235 header_libs: [
236 "avb_headers",
237 "bootimg_headers",
238 ],
239
Dan Willemsenab971b52018-08-29 14:58:02 -0700240 static_libs: [
241 "libziparchive",
242 "libsparse",
243 "libutils",
244 "liblog",
245 "libz",
246 "libdiagnose_usb",
247 "libbase",
248 "libcutils",
249 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800250 "liblp",
251 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700252 ],
253}
254
255//
256// Build host libfastboot.
257//
258
259cc_library_host_static {
260 name: "libfastboot",
261 defaults: ["fastboot_host_defaults"],
262
Dan Willemsenab971b52018-08-29 14:58:02 -0700263 srcs: [
264 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700265 "fastboot.cpp",
266 "fs.cpp",
267 "socket.cpp",
268 "tcp.cpp",
269 "udp.cpp",
270 "util.cpp",
271 "fastboot_driver.cpp",
272 ],
273
274 // Only version the final binaries
275 use_version_lib: false,
276 static_libs: ["libbuildversion"],
277
278 generated_headers: ["platform_tools_version"],
279
Chih-Hung Hsieh84006f52021-02-19 18:30:29 -0800280 tidy_flags: [
281 // DO NOT add quotes around header-filter flag regex argument,
282 // because build/soong will add quotes around the whole flag.
283 "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)",
284 ],
285
Dan Willemsenab971b52018-08-29 14:58:02 -0700286 target: {
287 windows: {
288 srcs: ["usb_windows.cpp"],
289
290 include_dirs: ["development/host/windows/usb/api"],
291 },
292 darwin: {
293 srcs: ["usb_osx.cpp"],
294 },
Jiyong Parkfd890282020-08-20 18:04:01 +0900295 linux: {
Dan Willemsenab971b52018-08-29 14:58:02 -0700296 srcs: ["usb_linux.cpp"],
297 },
298 },
299}
300
301//
302// Build host fastboot / fastboot.exe
303//
304
305cc_binary_host {
306 name: "fastboot",
307 defaults: ["fastboot_host_defaults"],
308
309 srcs: ["main.cpp"],
310 static_libs: ["libfastboot"],
311
312 required: [
313 "mke2fs",
314 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700315 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700316 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800317 dist: {
318 targets: [
319 "dist_files",
320 "sdk",
321 "win_sdk",
322 ],
323 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700324
325 target: {
326 not_windows: {
327 required: [
328 "e2fsdroid",
329 "mke2fs.conf",
330 "sload_f2fs",
331 ],
332 },
333 windows: {
334 required: ["AdbWinUsbApi"],
335 shared_libs: ["AdbWinApi"],
336 },
337 },
338}
339
340//
341// Build host fastboot_test.
342//
343
344cc_test_host {
345 name: "fastboot_test",
346 defaults: ["fastboot_host_defaults"],
347
348 srcs: [
349 "fastboot_test.cpp",
350 "socket_mock.cpp",
351 "socket_test.cpp",
352 "tcp_test.cpp",
353 "udp_test.cpp",
354 ],
355
356 static_libs: ["libfastboot"],
357
358 target: {
359 windows: {
360 shared_libs: ["AdbWinApi"],
361 },
362 windows_x86_64: {
363 // Avoid trying to build for win64
364 enabled: false,
365 },
366 },
367}