blob: 716fe9558b08647f99198026deb6474fdccdddf5 [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",
137 "libhidltransport",
138 "libhwbinder",
139 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700140 "liblp",
Tao Baob71eedf2018-08-06 19:13:38 -0700141 "libsparse",
142 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700143 ],
144
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700145 static_libs: [
146 "libhealthhalutils",
147 ],
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700148}
Dan Willemsenab971b52018-08-29 14:58:02 -0700149
150cc_defaults {
151 name: "fastboot_host_defaults",
152
153 use_version_lib: true,
154
155 cflags: [
156 "-Wall",
157 "-Wextra",
158 "-Werror",
159 "-Wunreachable-code",
160 ],
161
162 target: {
163 darwin: {
164 cflags: ["-Wno-unused-parameter"],
165 host_ldlibs: [
166 "-lpthread",
167 "-framework CoreFoundation",
168 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700169 ],
170 },
171 windows: {
172 enabled: true,
173
174 host_ldlibs: ["-lws2_32"],
175 },
David Anderson89569642018-11-16 15:53:35 -0800176 not_windows: {
177 static_libs: [
178 "libext4_utils",
179 ],
180 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700181 },
182
183 stl: "libc++_static",
184
185 // Don't add anything here, we don't want additional shared dependencies
186 // on the host fastboot tool, and shared libraries that link against libc++
187 // will violate ODR.
188 shared_libs: [],
189
190 header_libs: ["bootimg_headers"],
191 static_libs: [
192 "libziparchive",
193 "libsparse",
194 "libutils",
195 "liblog",
196 "libz",
197 "libdiagnose_usb",
198 "libbase",
199 "libcutils",
200 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800201 "liblp",
202 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700203 ],
204}
205
206//
207// Build host libfastboot.
208//
209
210cc_library_host_static {
211 name: "libfastboot",
212 defaults: ["fastboot_host_defaults"],
213
Dan Willemsenab971b52018-08-29 14:58:02 -0700214 srcs: [
215 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700216 "fastboot.cpp",
217 "fs.cpp",
218 "socket.cpp",
219 "tcp.cpp",
220 "udp.cpp",
221 "util.cpp",
222 "fastboot_driver.cpp",
223 ],
224
225 // Only version the final binaries
226 use_version_lib: false,
227 static_libs: ["libbuildversion"],
228
229 generated_headers: ["platform_tools_version"],
230
231 target: {
232 windows: {
233 srcs: ["usb_windows.cpp"],
234
235 include_dirs: ["development/host/windows/usb/api"],
236 },
237 darwin: {
238 srcs: ["usb_osx.cpp"],
239 },
240 linux_glibc: {
241 srcs: ["usb_linux.cpp"],
242 },
243 },
244}
245
246//
247// Build host fastboot / fastboot.exe
248//
249
250cc_binary_host {
251 name: "fastboot",
252 defaults: ["fastboot_host_defaults"],
253
254 srcs: ["main.cpp"],
255 static_libs: ["libfastboot"],
256
257 required: [
258 "mke2fs",
259 "make_f2fs",
260 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800261 dist: {
262 targets: [
263 "dist_files",
264 "sdk",
265 "win_sdk",
266 ],
267 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700268
269 target: {
270 not_windows: {
271 required: [
272 "e2fsdroid",
273 "mke2fs.conf",
274 "sload_f2fs",
275 ],
276 },
277 windows: {
278 required: ["AdbWinUsbApi"],
279 shared_libs: ["AdbWinApi"],
280 },
281 },
282}
283
284//
285// Build host fastboot_test.
286//
287
288cc_test_host {
289 name: "fastboot_test",
290 defaults: ["fastboot_host_defaults"],
291
292 srcs: [
293 "fastboot_test.cpp",
294 "socket_mock.cpp",
295 "socket_test.cpp",
296 "tcp_test.cpp",
297 "udp_test.cpp",
298 ],
299
300 static_libs: ["libfastboot"],
301
302 target: {
303 windows: {
304 shared_libs: ["AdbWinApi"],
305 },
306 windows_x86_64: {
307 // Avoid trying to build for win64
308 enabled: false,
309 },
310 },
311}