blob: 6673543d89bede73ea54fa95489610af551c6cc5 [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",
Josh Gao08718242020-03-27 18:09:56 -0700118 "device/usb.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700119 "device/usb_client.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700120 "device/tcp_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700121 "device/utility.cpp",
122 "device/variables.cpp",
Hongguang Chen1e239282020-04-22 14:25:45 -0700123 "socket.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700124 ],
125
126 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700127 "android.hardware.boot@1.0",
David Andersonab8f4662019-10-21 16:45:59 -0700128 "android.hardware.boot@1.1",
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700129 "android.hardware.fastboot@1.0",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700130 "android.hardware.health@2.0",
Tao Baob71eedf2018-08-06 19:13:38 -0700131 "libasyncio",
132 "libbase",
133 "libbootloader_message",
134 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700135 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700136 "libext4_utils",
137 "libfs_mgr",
David Anderson1d504e32019-01-15 14:38:20 -0800138 "libgsi",
Tao Baob71eedf2018-08-06 19:13:38 -0700139 "libhidlbase",
Tao Baob71eedf2018-08-06 19:13:38 -0700140 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700141 "liblp",
David Anderson220ddb12019-10-31 18:02:41 -0700142 "libprotobuf-cpp-lite",
Tao Baob71eedf2018-08-06 19:13:38 -0700143 "libsparse",
144 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700145 ],
146
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700147 static_libs: [
Hongguang Chen1e239282020-04-22 14:25:45 -0700148 "libgtest_prod",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700149 "libhealthhalutils",
David Anderson220ddb12019-10-31 18:02:41 -0700150 "libsnapshot_nobinder",
Yifan Hong66f01152020-04-16 11:05:16 -0700151 "update_metadata-protos",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700152 ],
Yifan Hong0e13bba2019-08-29 16:29:22 -0700153
154 header_libs: [
Steve Mucklea9b34432020-05-12 16:21:41 -0700155 "avb_headers",
Yifan Hong0e13bba2019-08-29 16:29:22 -0700156 "libsnapshot_headers",
157 ]
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700158}
Dan Willemsenab971b52018-08-29 14:58:02 -0700159
160cc_defaults {
161 name: "fastboot_host_defaults",
162
163 use_version_lib: true,
164
165 cflags: [
166 "-Wall",
167 "-Wextra",
168 "-Werror",
169 "-Wunreachable-code",
170 ],
171
172 target: {
173 darwin: {
174 cflags: ["-Wno-unused-parameter"],
175 host_ldlibs: [
176 "-lpthread",
177 "-framework CoreFoundation",
178 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700179 ],
180 },
181 windows: {
182 enabled: true,
183
184 host_ldlibs: ["-lws2_32"],
185 },
David Anderson89569642018-11-16 15:53:35 -0800186 not_windows: {
187 static_libs: [
188 "libext4_utils",
189 ],
190 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700191 },
192
193 stl: "libc++_static",
194
195 // Don't add anything here, we don't want additional shared dependencies
196 // on the host fastboot tool, and shared libraries that link against libc++
197 // will violate ODR.
198 shared_libs: [],
199
Chin-Ting Kuodf6a7802019-09-16 11:23:55 +0800200 header_libs: [
201 "avb_headers",
202 "bootimg_headers",
203 ],
204
Dan Willemsenab971b52018-08-29 14:58:02 -0700205 static_libs: [
206 "libziparchive",
207 "libsparse",
208 "libutils",
209 "liblog",
210 "libz",
211 "libdiagnose_usb",
212 "libbase",
213 "libcutils",
214 "libgtest_host",
David Anderson89569642018-11-16 15:53:35 -0800215 "liblp",
216 "libcrypto",
Dan Willemsenab971b52018-08-29 14:58:02 -0700217 ],
218}
219
220//
221// Build host libfastboot.
222//
223
224cc_library_host_static {
225 name: "libfastboot",
226 defaults: ["fastboot_host_defaults"],
227
Dan Willemsenab971b52018-08-29 14:58:02 -0700228 srcs: [
229 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700230 "fastboot.cpp",
231 "fs.cpp",
232 "socket.cpp",
233 "tcp.cpp",
234 "udp.cpp",
235 "util.cpp",
236 "fastboot_driver.cpp",
237 ],
238
239 // Only version the final binaries
240 use_version_lib: false,
241 static_libs: ["libbuildversion"],
242
243 generated_headers: ["platform_tools_version"],
244
245 target: {
246 windows: {
247 srcs: ["usb_windows.cpp"],
248
249 include_dirs: ["development/host/windows/usb/api"],
250 },
251 darwin: {
252 srcs: ["usb_osx.cpp"],
253 },
254 linux_glibc: {
255 srcs: ["usb_linux.cpp"],
256 },
257 },
258}
259
260//
261// Build host fastboot / fastboot.exe
262//
263
264cc_binary_host {
265 name: "fastboot",
266 defaults: ["fastboot_host_defaults"],
267
268 srcs: ["main.cpp"],
269 static_libs: ["libfastboot"],
270
271 required: [
272 "mke2fs",
273 "make_f2fs",
Jaegeuk Kima3896102020-07-17 20:30:41 -0700274 "make_f2fs_casefold",
Dan Willemsenab971b52018-08-29 14:58:02 -0700275 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800276 dist: {
277 targets: [
278 "dist_files",
279 "sdk",
280 "win_sdk",
281 ],
282 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700283
284 target: {
285 not_windows: {
286 required: [
287 "e2fsdroid",
288 "mke2fs.conf",
289 "sload_f2fs",
290 ],
291 },
292 windows: {
293 required: ["AdbWinUsbApi"],
294 shared_libs: ["AdbWinApi"],
295 },
296 },
297}
298
299//
300// Build host fastboot_test.
301//
302
303cc_test_host {
304 name: "fastboot_test",
305 defaults: ["fastboot_host_defaults"],
306
307 srcs: [
308 "fastboot_test.cpp",
309 "socket_mock.cpp",
310 "socket_test.cpp",
311 "tcp_test.cpp",
312 "udp_test.cpp",
313 ],
314
315 static_libs: ["libfastboot"],
316
317 target: {
318 windows: {
319 shared_libs: ["AdbWinApi"],
320 },
321 windows_x86_64: {
322 // Avoid trying to build for win64
323 enabled: false,
324 },
325 },
326}