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 | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 125 | "android.hardware.health@2.0", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 126 | "libadbd", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 127 | "libasyncio", |
| 128 | "libbase", |
| 129 | "libbootloader_message", |
| 130 | "libcutils", |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 131 | "libext2_uuid", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 132 | "libext4_utils", |
| 133 | "libfs_mgr", |
| 134 | "libhidlbase", |
| 135 | "libhidltransport", |
| 136 | "libhwbinder", |
| 137 | "liblog", |
David Anderson | 88ef0b1 | 2018-08-09 10:40:00 -0700 | [diff] [blame] | 138 | "liblp", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 139 | "libsparse", |
| 140 | "libutils", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 141 | ], |
| 142 | |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 143 | static_libs: [ |
| 144 | "libhealthhalutils", |
| 145 | ], |
| 146 | |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 147 | cpp_std: "c++17", |
| 148 | } |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 149 | |
| 150 | cc_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 Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 169 | ], |
| 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 | |
| 203 | cc_library_host_static { |
| 204 | name: "libfastboot", |
| 205 | defaults: ["fastboot_host_defaults"], |
| 206 | |
| 207 | cpp_std: "c++17", |
| 208 | srcs: [ |
| 209 | "bootimg_utils.cpp", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 210 | "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 | |
| 244 | cc_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 Willemsen | 3f439a7 | 2018-11-19 19:11:35 -0800 | [diff] [blame^] | 255 | dist: { |
| 256 | targets: [ |
| 257 | "dist_files", |
| 258 | "sdk", |
| 259 | "win_sdk", |
| 260 | ], |
| 261 | }, |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 262 | |
| 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 | |
| 282 | cc_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 | } |