blob: 3282f9b8589066b85da34d1f661be58a62c1cfd1 [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",
Aaron Wisnerdb511202018-06-26 15:38:35 -050046 ],
47
48 header_libs: [
Dan Willemsenab971b52018-08-29 14:58:02 -070049 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050050 ],
51
52 export_header_lib_headers: [
Dan Willemsenab971b52018-08-29 14:58:02 -070053 "bootimg_headers",
Aaron Wisnerdb511202018-06-26 15:38:35 -050054 ],
55
Aaron Wisnerdb511202018-06-26 15:38:35 -050056 target: {
Dan Willemsenab971b52018-08-29 14:58:02 -070057 linux: {
58 srcs: ["usb_linux.cpp"],
59 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050060
Dan Willemsenab971b52018-08-29 14:58:02 -070061 darwin: {
62 srcs: ["usb_osx.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050063
Dan Willemsenab971b52018-08-29 14:58:02 -070064 host_ldlibs: [
65 "-framework CoreFoundation",
66 "-framework IOKit",
67 ],
68 },
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050069
Dan Willemsenab971b52018-08-29 14:58:02 -070070 windows: {
71 srcs: ["usb_windows.cpp"],
Aaron Wisnera5ad20a2018-08-24 09:59:50 -050072
Dan Willemsenab971b52018-08-29 14:58:02 -070073 host_ldlibs: [
74 "-lws2_32",
75 ],
76 },
Aaron Wisnerdb511202018-06-26 15:38:35 -050077 },
78
79 cflags: [
Dan Willemsenab971b52018-08-29 14:58:02 -070080 "-Wall",
81 "-Wextra",
82 "-Werror",
83 "-Wunreachable-code",
Aaron Wisnerdb511202018-06-26 15:38:35 -050084 ],
85
86 export_include_dirs: ["."],
87
88}
Hridya Valsarajudea91b42018-07-17 11:14:01 -070089
90cc_defaults {
91 name: "fastboot_defaults",
92
93 cflags: [
94 "-Wall",
95 "-Wextra",
96 "-Werror",
97 "-Wvla",
98 ],
99 rtti: true,
100
101 clang_cflags: [
102 "-Wthread-safety",
103 ],
104}
105
106cc_binary {
107 name: "fastbootd",
108 defaults: ["fastboot_defaults"],
109
110 recovery: true,
111
112 srcs: [
113 "device/commands.cpp",
114 "device/fastboot_device.cpp",
David Anderson12211d12018-07-24 15:21:20 -0700115 "device/flashing.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700116 "device/main.cpp",
117 "device/usb_client.cpp",
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700118 "device/utility.cpp",
119 "device/variables.cpp",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700120 ],
121
122 shared_libs: [
Hridya Valsaraju31d2c262018-07-20 13:35:50 -0700123 "android.hardware.boot@1.0",
Hridya Valsarajubf9f8d12018-09-05 16:57:24 -0700124 "android.hardware.fastboot@1.0",
Hridya Valsaraju47658ca2018-09-28 11:41:22 -0700125 "android.hardware.health@2.0",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700126 "libadbd",
Tao Baob71eedf2018-08-06 19:13:38 -0700127 "libasyncio",
128 "libbase",
129 "libbootloader_message",
130 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700131 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700132 "libext4_utils",
133 "libfs_mgr",
134 "libhidlbase",
135 "libhidltransport",
136 "libhwbinder",
137 "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 ],
146
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700147 cpp_std: "c++17",
148}
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 },
176 },
177
178 stl: "libc++_static",
179
180 // Don't add anything here, we don't want additional shared dependencies
181 // on the host fastboot tool, and shared libraries that link against libc++
182 // will violate ODR.
183 shared_libs: [],
184
185 header_libs: ["bootimg_headers"],
186 static_libs: [
187 "libziparchive",
188 "libsparse",
189 "libutils",
190 "liblog",
191 "libz",
192 "libdiagnose_usb",
193 "libbase",
194 "libcutils",
195 "libgtest_host",
196 ],
197}
198
199//
200// Build host libfastboot.
201//
202
203cc_library_host_static {
204 name: "libfastboot",
205 defaults: ["fastboot_host_defaults"],
206
207 cpp_std: "c++17",
208 srcs: [
209 "bootimg_utils.cpp",
Dan Willemsenab971b52018-08-29 14:58:02 -0700210 "fastboot.cpp",
211 "fs.cpp",
212 "socket.cpp",
213 "tcp.cpp",
214 "udp.cpp",
215 "util.cpp",
216 "fastboot_driver.cpp",
217 ],
218
219 // Only version the final binaries
220 use_version_lib: false,
221 static_libs: ["libbuildversion"],
222
223 generated_headers: ["platform_tools_version"],
224
225 target: {
226 windows: {
227 srcs: ["usb_windows.cpp"],
228
229 include_dirs: ["development/host/windows/usb/api"],
230 },
231 darwin: {
232 srcs: ["usb_osx.cpp"],
233 },
234 linux_glibc: {
235 srcs: ["usb_linux.cpp"],
236 },
237 },
238}
239
240//
241// Build host fastboot / fastboot.exe
242//
243
244cc_binary_host {
245 name: "fastboot",
246 defaults: ["fastboot_host_defaults"],
247
248 srcs: ["main.cpp"],
249 static_libs: ["libfastboot"],
250
251 required: [
252 "mke2fs",
253 "make_f2fs",
254 ],
Dan Willemsen3f439a72018-11-19 19:11:35 -0800255 dist: {
256 targets: [
257 "dist_files",
258 "sdk",
259 "win_sdk",
260 ],
261 },
Dan Willemsenab971b52018-08-29 14:58:02 -0700262
263 target: {
264 not_windows: {
265 required: [
266 "e2fsdroid",
267 "mke2fs.conf",
268 "sload_f2fs",
269 ],
270 },
271 windows: {
272 required: ["AdbWinUsbApi"],
273 shared_libs: ["AdbWinApi"],
274 },
275 },
276}
277
278//
279// Build host fastboot_test.
280//
281
282cc_test_host {
283 name: "fastboot_test",
284 defaults: ["fastboot_host_defaults"],
285
286 srcs: [
287 "fastboot_test.cpp",
288 "socket_mock.cpp",
289 "socket_test.cpp",
290 "tcp_test.cpp",
291 "udp_test.cpp",
292 ],
293
294 static_libs: ["libfastboot"],
295
296 target: {
297 windows: {
298 shared_libs: ["AdbWinApi"],
299 },
300 windows_x86_64: {
301 // Avoid trying to build for win64
302 enabled: false,
303 },
304 },
305}