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 | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 124 | "libadbd", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 125 | "libasyncio", |
| 126 | "libbase", |
| 127 | "libbootloader_message", |
| 128 | "libcutils", |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 129 | "libext2_uuid", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 130 | "libext4_utils", |
| 131 | "libfs_mgr", |
| 132 | "libhidlbase", |
| 133 | "libhidltransport", |
| 134 | "libhwbinder", |
| 135 | "liblog", |
David Anderson | 88ef0b1 | 2018-08-09 10:40:00 -0700 | [diff] [blame] | 136 | "liblp", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 137 | "libsparse", |
| 138 | "libutils", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 139 | ], |
| 140 | |
| 141 | cpp_std: "c++17", |
| 142 | } |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 143 | |
| 144 | cc_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 Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 163 | ], |
| 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 | |
| 197 | cc_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 | |
| 239 | cc_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 | |
| 270 | cc_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 | } |