blob: 6b175af7d28729a6dd3defdfb57bb92212f1ce4c [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 Valsarajudea91b42018-07-17 11:14:01 -0700125 "libadbd",
Tao Baob71eedf2018-08-06 19:13:38 -0700126 "libasyncio",
127 "libbase",
128 "libbootloader_message",
129 "libcutils",
David Anderson0d4277d2018-07-31 13:27:37 -0700130 "libext2_uuid",
Tao Baob71eedf2018-08-06 19:13:38 -0700131 "libext4_utils",
132 "libfs_mgr",
133 "libhidlbase",
134 "libhidltransport",
135 "libhwbinder",
136 "liblog",
David Anderson88ef0b12018-08-09 10:40:00 -0700137 "liblp",
Tao Baob71eedf2018-08-06 19:13:38 -0700138 "libsparse",
139 "libutils",
Hridya Valsarajudea91b42018-07-17 11:14:01 -0700140 ],
141
142 cpp_std: "c++17",
143}
Dan Willemsenab971b52018-08-29 14:58:02 -0700144
145cc_defaults {
146 name: "fastboot_host_defaults",
147
148 use_version_lib: true,
149
150 cflags: [
151 "-Wall",
152 "-Wextra",
153 "-Werror",
154 "-Wunreachable-code",
155 ],
156
157 target: {
158 darwin: {
159 cflags: ["-Wno-unused-parameter"],
160 host_ldlibs: [
161 "-lpthread",
162 "-framework CoreFoundation",
163 "-framework IOKit",
Dan Willemsenab971b52018-08-29 14:58:02 -0700164 ],
165 },
166 windows: {
167 enabled: true,
168
169 host_ldlibs: ["-lws2_32"],
170 },
171 },
172
173 stl: "libc++_static",
174
175 // Don't add anything here, we don't want additional shared dependencies
176 // on the host fastboot tool, and shared libraries that link against libc++
177 // will violate ODR.
178 shared_libs: [],
179
180 header_libs: ["bootimg_headers"],
181 static_libs: [
182 "libziparchive",
183 "libsparse",
184 "libutils",
185 "liblog",
186 "libz",
187 "libdiagnose_usb",
188 "libbase",
189 "libcutils",
190 "libgtest_host",
191 ],
192}
193
194//
195// Build host libfastboot.
196//
197
198cc_library_host_static {
199 name: "libfastboot",
200 defaults: ["fastboot_host_defaults"],
201
202 cpp_std: "c++17",
203 srcs: [
204 "bootimg_utils.cpp",
205 "engine.cpp",
206 "fastboot.cpp",
207 "fs.cpp",
208 "socket.cpp",
209 "tcp.cpp",
210 "udp.cpp",
211 "util.cpp",
212 "fastboot_driver.cpp",
213 ],
214
215 // Only version the final binaries
216 use_version_lib: false,
217 static_libs: ["libbuildversion"],
218
219 generated_headers: ["platform_tools_version"],
220
221 target: {
222 windows: {
223 srcs: ["usb_windows.cpp"],
224
225 include_dirs: ["development/host/windows/usb/api"],
226 },
227 darwin: {
228 srcs: ["usb_osx.cpp"],
229 },
230 linux_glibc: {
231 srcs: ["usb_linux.cpp"],
232 },
233 },
234}
235
236//
237// Build host fastboot / fastboot.exe
238//
239
240cc_binary_host {
241 name: "fastboot",
242 defaults: ["fastboot_host_defaults"],
243
244 srcs: ["main.cpp"],
245 static_libs: ["libfastboot"],
246
247 required: [
248 "mke2fs",
249 "make_f2fs",
250 ],
251
252 target: {
253 not_windows: {
254 required: [
255 "e2fsdroid",
256 "mke2fs.conf",
257 "sload_f2fs",
258 ],
259 },
260 windows: {
261 required: ["AdbWinUsbApi"],
262 shared_libs: ["AdbWinApi"],
263 },
264 },
265}
266
267//
268// Build host fastboot_test.
269//
270
271cc_test_host {
272 name: "fastboot_test",
273 defaults: ["fastboot_host_defaults"],
274
275 srcs: [
276 "fastboot_test.cpp",
277 "socket_mock.cpp",
278 "socket_test.cpp",
279 "tcp_test.cpp",
280 "udp_test.cpp",
281 ],
282
283 static_libs: ["libfastboot"],
284
285 target: {
286 windows: {
287 shared_libs: ["AdbWinApi"],
288 },
289 windows_x86_64: {
290 // Avoid trying to build for win64
291 enabled: false,
292 },
293 },
294}