blob: 02a887ec8d45fdfcc6286c821942b8bf67a5642e [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)
Aaron Wisnerdb511202018-06-26 15:38:35 -050017cc_library_host_static {
18 name: "libfastboot2",
19
20 //host_supported: true,
21
22 compile_multilib: "first",
23 srcs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070024 "bootimg_utils.cpp",
25 "fs.cpp",
26 "socket.cpp",
27 "tcp.cpp",
28 "udp.cpp",
29 "util.cpp",
30 "fastboot_driver.cpp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050031 ],
32
33 static_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070034 "libziparchive",
35 "libsparse",
36 "libutils",
37 "liblog",
38 "libz",
39 "libdiagnose_usb",
40 "libbase",
41 "libcutils",
42 "libgtest",
43 "libgtest_main",
44 "libbase",
45 "libadb_host",
David Anderson89569642018-11-16 15:53:35 -080046 "liblp",
Aaron Wisnerdb511202018-06-26 15:38:35 -050047 ],
48
49 header_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070050 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050051 ],
52
53 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070054 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050055 ],
56
Aaron Wisnerdb511202018-06-26 15:38:35 -050057 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070058 linux: {
59 srcs: ["usb_linux.cpp"],
60 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050061
Dan Willemsenab971b52018-08-29 14:58:02 -070062 darwin: {
63 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050064
Dan Willemsenab971b52018-08-29 14:58:02 -070065 host_ldlibs: [
66 "-framework CoreFoundation",
67 "-framework IOKit",
68 ],
69 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050070
Dan Willemsenab971b52018-08-29 14:58:02 -070071 windows: {
72 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050073
Dan Willemsenab971b52018-08-29 14:58:02 -070074 host_ldlibs: [
75 "-lws2_32",
76 ],
77 },
Aaron Wisnerdb511202018-06-26 15:38:35 -050078 },
79
80 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -070081 "-Wall",
82 "-Wextra",
83 "-Werror",
84 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -050085 ],
86
87 export_include_dirs: ["."],
88
89}
Hridya Valsarajudea91b42018-07-17 11:14:01 -070090
91cc_defaults {
92 name: "fastboot_defaults",
93
94 cflags: [
95 "-Wall",
96 "-Wextra",
97 "-Werror",
98 "-Wvla",
99 ],
100 rtti: true,
101
102 clang_cflags: [
103 "-Wthread-safety",
104 ],
105}
106
107cc_binary {
108 name: "fastbootd",
109 defaults: ["fastboot_defaults"],
110
111 recovery: true,
112
113 srcs: [
114 "device/commands.cpp",
115 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700116 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700117 "device/main.cpp",
118 "device/usb_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700119 "device/utility.cpp",
120 "device/variables.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700121 ],
122
123 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700124 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700125 "android.hardware.boot@1.1",
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700126 "android.hardware.fastboot@1.0",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700127 "android.hardware.health@2.0",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700128 "libadbd",
Tao Baob71eedf2018-08-06 19:13:38 -0700129 "libasyncio",
130 "libbase",
131 "libbootloader_message",
132 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700133 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700134 "libext4_utils",
135 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800136 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700137 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700138 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700139 "liblp",
Tao Baob71eedf2018-08-06 19:13:38 -0700140 "libsparse",
141 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700142 ],
143
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700144 static_libs: [
145 "libhealthhalutils",
146 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700147
148 header_libs: [
149 "libsnapshot_headers",
150 ]
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700151}
Dan Willemsenab971b52018-08-29 14:58:02 -0700152
153cc_defaults {
154 name: "fastboot_host_defaults",
155
156 use_version_lib: true,
157
158 cflags: [
159 "-Wall",
160 "-Wextra",
161 "-Werror",
162 "-Wunreachable-code",
163 ],
164
165 target: {
166 darwin: {
167 cflags: ["-Wno-unused-parameter"],
168 host_ldlibs: [
169 "-lpthread",
170 "-framework CoreFoundation",
171 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700172 ],
173 },
174 windows: {
175 enabled: true,
176
177 host_ldlibs: ["-lws2_32"],
178 },
David Anderson89569642018-11-16 15:53:35 -0800179 not_windows: {
180 static_libs: [
181 "libext4_utils",
182 ],
183 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700184 },
185
186 stl: "libc++_static",
187
188 // Don't add anything here, we don't want additional shared dependencies
189 // on the host fastboot tool, and shared libraries that link against libc++
190 // will violate ODR.
191 shared_libs: [],
192
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800193 header_libs: [
194 "avb_headers",
195 "bootimg_headers",
196 ],
197
Dan Willemsenab971b52018-08-29 14:58:02 -0700198 static_libs: [
199 "libziparchive",
200 "libsparse",
201 "libutils",
202 "liblog",
203 "libz",
204 "libdiagnose_usb",
205 "libbase",
206 "libcutils",
207 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800208 "liblp",
209 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700210 ],
211}
212
213//
214// Build host libfastboot.
215//
216
217cc_library_host_static {
218 name: "libfastboot",
219 defaults: ["fastboot_host_defaults"],
220
Dan Willemsenab971b52018-08-29 14:58:02 -0700221 srcs: [
222 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700223 "fastboot.cpp",
224 "fs.cpp",
225 "socket.cpp",
226 "tcp.cpp",
227 "udp.cpp",
228 "util.cpp",
229 "fastboot_driver.cpp",
230 ],
231
232 // Only version the final binaries
233 use_version_lib: false,
234 static_libs: ["libbuildversion"],
235
236 generated_headers: ["platform_tools_version"],
237
238 target: {
239 windows: {
240 srcs: ["usb_windows.cpp"],
241
242 include_dirs: ["development/host/windows/usb/api"],
243 },
244 darwin: {
245 srcs: ["usb_osx.cpp"],
246 },
247 linux_glibc: {
248 srcs: ["usb_linux.cpp"],
249 },
250 },
251}
252
253//
254// Build host fastboot / fastboot.exe
255//
256
257cc_binary_host {
258 name: "fastboot",
259 defaults: ["fastboot_host_defaults"],
260
261 srcs: ["main.cpp"],
262 static_libs: ["libfastboot"],
263
264 required: [
265 "mke2fs",
266 "make_f2fs",
267 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800268 dist: {
269 targets: [
270 "dist_files",
271 "sdk",
272 "win_sdk",
273 ],
274 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700275
276 target: {
277 not_windows: {
278 required: [
279 "e2fsdroid",
280 "mke2fs.conf",
281 "sload_f2fs",
282 ],
283 },
284 windows: {
285 required: ["AdbWinUsbApi"],
286 shared_libs: ["AdbWinApi"],
287 },
288 },
289}
290
291//
292// Build host fastboot_test.
293//
294
295cc_test_host {
296 name: "fastboot_test",
297 defaults: ["fastboot_host_defaults"],
298
299 srcs: [
300 "fastboot_test.cpp",
301 "socket_mock.cpp",
302 "socket_test.cpp",
303 "tcp_test.cpp",
304 "udp_test.cpp",
305 ],
306
307 static_libs: ["libfastboot"],
308
309 target: {
310 windows: {
311 shared_libs: ["AdbWinApi"],
312 },
313 windows_x86_64: {
314 // Avoid trying to build for win64
315 enabled: false,
316 },
317 },
318}