blob: f452a64397c85f5a4dead0db7cbc92e142ea63b8 [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",
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700125 "android.hardware.fastboot@1.0",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700126 "android.hardware.health@2.0",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700127 "libadbd",
Tao Baob71eedf2018-08-06 19:13:38 -0700128 "libasyncio",
129 "libbase",
130 "libbootloader_message",
131 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700132 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700133 "libext4_utils",
134 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800135 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700136 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700137 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700138 "liblp",
Tao Baob71eedf2018-08-06 19:13:38 -0700139 "libsparse",
140 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700141 ],
142
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700143 static_libs: [
144 "libhealthhalutils",
145 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700146
147 header_libs: [
148 "libsnapshot_headers",
149 ]
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700150}
Dan Willemsenab971b52018-08-29 14:58:02 -0700151
152cc_defaults {
153 name: "fastboot_host_defaults",
154
155 use_version_lib: true,
156
157 cflags: [
158 "-Wall",
159 "-Wextra",
160 "-Werror",
161 "-Wunreachable-code",
162 ],
163
164 target: {
165 darwin: {
166 cflags: ["-Wno-unused-parameter"],
167 host_ldlibs: [
168 "-lpthread",
169 "-framework CoreFoundation",
170 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700171 ],
172 },
173 windows: {
174 enabled: true,
175
176 host_ldlibs: ["-lws2_32"],
177 },
David Anderson89569642018-11-16 15:53:35 -0800178 not_windows: {
179 static_libs: [
180 "libext4_utils",
181 ],
182 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700183 },
184
185 stl: "libc++_static",
186
187 // Don't add anything here, we don't want additional shared dependencies
188 // on the host fastboot tool, and shared libraries that link against libc++
189 // will violate ODR.
190 shared_libs: [],
191
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800192 header_libs: [
193 "avb_headers",
194 "bootimg_headers",
195 ],
196
Dan Willemsenab971b52018-08-29 14:58:02 -0700197 static_libs: [
198 "libziparchive",
199 "libsparse",
200 "libutils",
201 "liblog",
202 "libz",
203 "libdiagnose_usb",
204 "libbase",
205 "libcutils",
206 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800207 "liblp",
208 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700209 ],
210}
211
212//
213// Build host libfastboot.
214//
215
216cc_library_host_static {
217 name: "libfastboot",
218 defaults: ["fastboot_host_defaults"],
219
Dan Willemsenab971b52018-08-29 14:58:02 -0700220 srcs: [
221 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700222 "fastboot.cpp",
223 "fs.cpp",
224 "socket.cpp",
225 "tcp.cpp",
226 "udp.cpp",
227 "util.cpp",
228 "fastboot_driver.cpp",
229 ],
230
231 // Only version the final binaries
232 use_version_lib: false,
233 static_libs: ["libbuildversion"],
234
235 generated_headers: ["platform_tools_version"],
236
237 target: {
238 windows: {
239 srcs: ["usb_windows.cpp"],
240
241 include_dirs: ["development/host/windows/usb/api"],
242 },
243 darwin: {
244 srcs: ["usb_osx.cpp"],
245 },
246 linux_glibc: {
247 srcs: ["usb_linux.cpp"],
248 },
249 },
250}
251
252//
253// Build host fastboot / fastboot.exe
254//
255
256cc_binary_host {
257 name: "fastboot",
258 defaults: ["fastboot_host_defaults"],
259
260 srcs: ["main.cpp"],
261 static_libs: ["libfastboot"],
262
263 required: [
264 "mke2fs",
265 "make_f2fs",
266 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800267 dist: {
268 targets: [
269 "dist_files",
270 "sdk",
271 "win_sdk",
272 ],
273 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700274
275 target: {
276 not_windows: {
277 required: [
278 "e2fsdroid",
279 "mke2fs.conf",
280 "sload_f2fs",
281 ],
282 },
283 windows: {
284 required: ["AdbWinUsbApi"],
285 shared_libs: ["AdbWinApi"],
286 },
287 },
288}
289
290//
291// Build host fastboot_test.
292//
293
294cc_test_host {
295 name: "fastboot_test",
296 defaults: ["fastboot_host_defaults"],
297
298 srcs: [
299 "fastboot_test.cpp",
300 "socket_mock.cpp",
301 "socket_test.cpp",
302 "tcp_test.cpp",
303 "udp_test.cpp",
304 ],
305
306 static_libs: ["libfastboot"],
307
308 target: {
309 windows: {
310 shared_libs: ["AdbWinApi"],
311 },
312 windows_x86_64: {
313 // Avoid trying to build for win64
314 enabled: false,
315 },
316 },
317}