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