Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 1 | // 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 Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 15 | // 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 Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 17 | cc_library_host_static { |
| 18 | name: "libfastboot2", |
| 19 | |
| 20 | //host_supported: true, |
| 21 | |
| 22 | compile_multilib: "first", |
| 23 | srcs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 24 | "bootimg_utils.cpp", |
| 25 | "fs.cpp", |
| 26 | "socket.cpp", |
| 27 | "tcp.cpp", |
| 28 | "udp.cpp", |
| 29 | "util.cpp", |
| 30 | "fastboot_driver.cpp", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 31 | ], |
| 32 | |
| 33 | static_libs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 34 | "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 Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 46 | ], |
| 47 | |
| 48 | header_libs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 49 | "bootimg_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 50 | ], |
| 51 | |
| 52 | export_header_lib_headers: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 53 | "bootimg_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 54 | ], |
| 55 | |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 56 | target: { |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 57 | linux: { |
| 58 | srcs: ["usb_linux.cpp"], |
| 59 | }, |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 60 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 61 | darwin: { |
| 62 | srcs: ["usb_osx.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 63 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 64 | host_ldlibs: [ |
| 65 | "-framework CoreFoundation", |
| 66 | "-framework IOKit", |
| 67 | ], |
| 68 | }, |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 69 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 70 | windows: { |
| 71 | srcs: ["usb_windows.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 72 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 73 | host_ldlibs: [ |
| 74 | "-lws2_32", |
| 75 | ], |
| 76 | }, |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 77 | }, |
| 78 | |
| 79 | cflags: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 80 | "-Wall", |
| 81 | "-Wextra", |
| 82 | "-Werror", |
| 83 | "-Wunreachable-code", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 84 | ], |
| 85 | |
| 86 | export_include_dirs: ["."], |
| 87 | |
| 88 | } |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 89 | |
| 90 | cc_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 | |
| 106 | cc_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 Anderson | 12211d1 | 2018-07-24 15:21:20 -0700 | [diff] [blame] | 115 | "device/flashing.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 116 | "device/main.cpp", |
| 117 | "device/usb_client.cpp", |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 118 | "device/utility.cpp", |
| 119 | "device/variables.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 120 | ], |
| 121 | |
| 122 | shared_libs: [ |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 123 | "android.hardware.boot@1.0", |
Hridya Valsaraju | bf9f8d1 | 2018-09-05 16:57:24 -0700 | [diff] [blame] | 124 | "android.hardware.fastboot@1.0", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 125 | "libadbd", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 126 | "libasyncio", |
| 127 | "libbase", |
| 128 | "libbootloader_message", |
| 129 | "libcutils", |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 130 | "libext2_uuid", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 131 | "libext4_utils", |
| 132 | "libfs_mgr", |
| 133 | "libhidlbase", |
| 134 | "libhidltransport", |
| 135 | "libhwbinder", |
| 136 | "liblog", |
David Anderson | 88ef0b1 | 2018-08-09 10:40:00 -0700 | [diff] [blame] | 137 | "liblp", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 138 | "libsparse", |
| 139 | "libutils", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 140 | ], |
| 141 | |
| 142 | cpp_std: "c++17", |
| 143 | } |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 144 | |
| 145 | cc_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 Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 164 | ], |
| 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 | |
| 198 | cc_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 | |
| 240 | cc_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 | |
| 271 | cc_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 | } |