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) |
Bob Badour | d69ad69 | 2021-02-16 19:02:14 -0800 | [diff] [blame^] | 17 | package { |
| 18 | default_applicable_licenses: ["system_core_fastboot_license"], |
| 19 | } |
| 20 | |
| 21 | // Added automatically by a large-scale-change that took the approach of |
| 22 | // 'apply every license found to every target'. While this makes sure we respect |
| 23 | // every license restriction, it may not be entirely correct. |
| 24 | // |
| 25 | // e.g. GPL in an MIT project might only apply to the contrib/ directory. |
| 26 | // |
| 27 | // Please consider splitting the single license below into multiple licenses, |
| 28 | // taking care not to lose any license_kind information, and overriding the |
| 29 | // default license using the 'licenses: [...]' property on targets as needed. |
| 30 | // |
| 31 | // For unused files, consider creating a 'fileGroup' with "//visibility:private" |
| 32 | // to attach the license to, and including a comment whether the files may be |
| 33 | // used in the current project. |
| 34 | // See: http://go/android-license-faq |
| 35 | license { |
| 36 | name: "system_core_fastboot_license", |
| 37 | visibility: [":__subpackages__"], |
| 38 | license_kinds: [ |
| 39 | "SPDX-license-identifier-Apache-2.0", |
| 40 | "SPDX-license-identifier-BSD", |
| 41 | ], |
| 42 | // large-scale-change unable to identify any license_text files |
| 43 | } |
| 44 | |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 45 | cc_library_host_static { |
| 46 | name: "libfastboot2", |
| 47 | |
| 48 | //host_supported: true, |
| 49 | |
| 50 | compile_multilib: "first", |
| 51 | srcs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 52 | "bootimg_utils.cpp", |
| 53 | "fs.cpp", |
| 54 | "socket.cpp", |
| 55 | "tcp.cpp", |
| 56 | "udp.cpp", |
| 57 | "util.cpp", |
| 58 | "fastboot_driver.cpp", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 59 | ], |
| 60 | |
| 61 | static_libs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 62 | "libziparchive", |
| 63 | "libsparse", |
| 64 | "libutils", |
| 65 | "liblog", |
| 66 | "libz", |
| 67 | "libdiagnose_usb", |
| 68 | "libbase", |
| 69 | "libcutils", |
| 70 | "libgtest", |
| 71 | "libgtest_main", |
| 72 | "libbase", |
| 73 | "libadb_host", |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 74 | "liblp", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 75 | ], |
| 76 | |
| 77 | header_libs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 78 | "bootimg_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 79 | ], |
| 80 | |
| 81 | export_header_lib_headers: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 82 | "bootimg_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 83 | ], |
| 84 | |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 85 | target: { |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 86 | linux: { |
| 87 | srcs: ["usb_linux.cpp"], |
| 88 | }, |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 89 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 90 | darwin: { |
| 91 | srcs: ["usb_osx.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 92 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 93 | host_ldlibs: [ |
| 94 | "-framework CoreFoundation", |
| 95 | "-framework IOKit", |
| 96 | ], |
| 97 | }, |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 98 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 99 | windows: { |
| 100 | srcs: ["usb_windows.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 101 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 102 | host_ldlibs: [ |
| 103 | "-lws2_32", |
| 104 | ], |
| 105 | }, |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 106 | }, |
| 107 | |
| 108 | cflags: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 109 | "-Wall", |
| 110 | "-Wextra", |
| 111 | "-Werror", |
| 112 | "-Wunreachable-code", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 113 | ], |
| 114 | |
| 115 | export_include_dirs: ["."], |
| 116 | |
| 117 | } |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 118 | |
| 119 | cc_defaults { |
| 120 | name: "fastboot_defaults", |
| 121 | |
| 122 | cflags: [ |
| 123 | "-Wall", |
| 124 | "-Wextra", |
| 125 | "-Werror", |
| 126 | "-Wvla", |
| 127 | ], |
| 128 | rtti: true, |
| 129 | |
| 130 | clang_cflags: [ |
| 131 | "-Wthread-safety", |
| 132 | ], |
| 133 | } |
| 134 | |
| 135 | cc_binary { |
| 136 | name: "fastbootd", |
| 137 | defaults: ["fastboot_defaults"], |
| 138 | |
| 139 | recovery: true, |
| 140 | |
| 141 | srcs: [ |
| 142 | "device/commands.cpp", |
| 143 | "device/fastboot_device.cpp", |
David Anderson | 12211d1 | 2018-07-24 15:21:20 -0700 | [diff] [blame] | 144 | "device/flashing.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 145 | "device/main.cpp", |
Josh Gao | 0871824 | 2020-03-27 18:09:56 -0700 | [diff] [blame] | 146 | "device/usb.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 147 | "device/usb_client.cpp", |
Hongguang Chen | 1e23928 | 2020-04-22 14:25:45 -0700 | [diff] [blame] | 148 | "device/tcp_client.cpp", |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 149 | "device/utility.cpp", |
| 150 | "device/variables.cpp", |
Hongguang Chen | 1e23928 | 2020-04-22 14:25:45 -0700 | [diff] [blame] | 151 | "socket.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 152 | ], |
| 153 | |
| 154 | shared_libs: [ |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 155 | "android.hardware.boot@1.0", |
David Anderson | ab8f466 | 2019-10-21 16:45:59 -0700 | [diff] [blame] | 156 | "android.hardware.boot@1.1", |
josephjang | 2906975 | 2020-09-23 16:28:03 +0800 | [diff] [blame] | 157 | "android.hardware.fastboot@1.1", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 158 | "android.hardware.health@2.0", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 159 | "libasyncio", |
| 160 | "libbase", |
| 161 | "libbootloader_message", |
| 162 | "libcutils", |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 163 | "libext2_uuid", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 164 | "libext4_utils", |
| 165 | "libfs_mgr", |
David Anderson | 1d504e3 | 2019-01-15 14:38:20 -0800 | [diff] [blame] | 166 | "libgsi", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 167 | "libhidlbase", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 168 | "liblog", |
David Anderson | 88ef0b1 | 2018-08-09 10:40:00 -0700 | [diff] [blame] | 169 | "liblp", |
David Anderson | 220ddb1 | 2019-10-31 18:02:41 -0700 | [diff] [blame] | 170 | "libprotobuf-cpp-lite", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 171 | "libsparse", |
| 172 | "libutils", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 173 | ], |
| 174 | |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 175 | static_libs: [ |
Hongguang Chen | 1e23928 | 2020-04-22 14:25:45 -0700 | [diff] [blame] | 176 | "libgtest_prod", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 177 | "libhealthhalutils", |
David Anderson | aca0bea | 2020-09-21 16:34:25 -0700 | [diff] [blame] | 178 | "libsnapshot_cow", |
David Anderson | 220ddb1 | 2019-10-31 18:02:41 -0700 | [diff] [blame] | 179 | "libsnapshot_nobinder", |
Yifan Hong | 66f0115 | 2020-04-16 11:05:16 -0700 | [diff] [blame] | 180 | "update_metadata-protos", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 181 | ], |
Yifan Hong | 0e13bba | 2019-08-29 16:29:22 -0700 | [diff] [blame] | 182 | |
| 183 | header_libs: [ |
Steve Muckle | a9b3443 | 2020-05-12 16:21:41 -0700 | [diff] [blame] | 184 | "avb_headers", |
Yifan Hong | 0e13bba | 2019-08-29 16:29:22 -0700 | [diff] [blame] | 185 | "libsnapshot_headers", |
| 186 | ] |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 187 | } |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 188 | |
| 189 | cc_defaults { |
| 190 | name: "fastboot_host_defaults", |
| 191 | |
| 192 | use_version_lib: true, |
| 193 | |
| 194 | cflags: [ |
| 195 | "-Wall", |
| 196 | "-Wextra", |
| 197 | "-Werror", |
| 198 | "-Wunreachable-code", |
| 199 | ], |
| 200 | |
| 201 | target: { |
| 202 | darwin: { |
| 203 | cflags: ["-Wno-unused-parameter"], |
| 204 | host_ldlibs: [ |
| 205 | "-lpthread", |
| 206 | "-framework CoreFoundation", |
| 207 | "-framework IOKit", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 208 | ], |
| 209 | }, |
| 210 | windows: { |
| 211 | enabled: true, |
| 212 | |
| 213 | host_ldlibs: ["-lws2_32"], |
| 214 | }, |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 215 | not_windows: { |
| 216 | static_libs: [ |
| 217 | "libext4_utils", |
| 218 | ], |
| 219 | }, |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 220 | }, |
| 221 | |
| 222 | stl: "libc++_static", |
| 223 | |
| 224 | // Don't add anything here, we don't want additional shared dependencies |
| 225 | // on the host fastboot tool, and shared libraries that link against libc++ |
| 226 | // will violate ODR. |
| 227 | shared_libs: [], |
| 228 | |
Chin-Ting Kuo | df6a780 | 2019-09-16 11:23:55 +0800 | [diff] [blame] | 229 | header_libs: [ |
| 230 | "avb_headers", |
| 231 | "bootimg_headers", |
| 232 | ], |
| 233 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 234 | static_libs: [ |
| 235 | "libziparchive", |
| 236 | "libsparse", |
| 237 | "libutils", |
| 238 | "liblog", |
| 239 | "libz", |
| 240 | "libdiagnose_usb", |
| 241 | "libbase", |
| 242 | "libcutils", |
| 243 | "libgtest_host", |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 244 | "liblp", |
| 245 | "libcrypto", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 246 | ], |
| 247 | } |
| 248 | |
| 249 | // |
| 250 | // Build host libfastboot. |
| 251 | // |
| 252 | |
| 253 | cc_library_host_static { |
| 254 | name: "libfastboot", |
| 255 | defaults: ["fastboot_host_defaults"], |
| 256 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 257 | srcs: [ |
| 258 | "bootimg_utils.cpp", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 259 | "fastboot.cpp", |
| 260 | "fs.cpp", |
| 261 | "socket.cpp", |
| 262 | "tcp.cpp", |
| 263 | "udp.cpp", |
| 264 | "util.cpp", |
| 265 | "fastboot_driver.cpp", |
| 266 | ], |
| 267 | |
| 268 | // Only version the final binaries |
| 269 | use_version_lib: false, |
| 270 | static_libs: ["libbuildversion"], |
| 271 | |
| 272 | generated_headers: ["platform_tools_version"], |
| 273 | |
| 274 | target: { |
| 275 | windows: { |
| 276 | srcs: ["usb_windows.cpp"], |
| 277 | |
| 278 | include_dirs: ["development/host/windows/usb/api"], |
| 279 | }, |
| 280 | darwin: { |
| 281 | srcs: ["usb_osx.cpp"], |
| 282 | }, |
Jiyong Park | fd89028 | 2020-08-20 18:04:01 +0900 | [diff] [blame] | 283 | linux: { |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 284 | srcs: ["usb_linux.cpp"], |
| 285 | }, |
| 286 | }, |
| 287 | } |
| 288 | |
| 289 | // |
| 290 | // Build host fastboot / fastboot.exe |
| 291 | // |
| 292 | |
| 293 | cc_binary_host { |
| 294 | name: "fastboot", |
| 295 | defaults: ["fastboot_host_defaults"], |
| 296 | |
| 297 | srcs: ["main.cpp"], |
| 298 | static_libs: ["libfastboot"], |
| 299 | |
| 300 | required: [ |
| 301 | "mke2fs", |
| 302 | "make_f2fs", |
Jaegeuk Kim | a389610 | 2020-07-17 20:30:41 -0700 | [diff] [blame] | 303 | "make_f2fs_casefold", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 304 | ], |
Dan Willemsen | 3f439a7 | 2018-11-19 19:11:35 -0800 | [diff] [blame] | 305 | dist: { |
| 306 | targets: [ |
| 307 | "dist_files", |
| 308 | "sdk", |
| 309 | "win_sdk", |
| 310 | ], |
| 311 | }, |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 312 | |
| 313 | target: { |
| 314 | not_windows: { |
| 315 | required: [ |
| 316 | "e2fsdroid", |
| 317 | "mke2fs.conf", |
| 318 | "sload_f2fs", |
| 319 | ], |
| 320 | }, |
| 321 | windows: { |
| 322 | required: ["AdbWinUsbApi"], |
| 323 | shared_libs: ["AdbWinApi"], |
| 324 | }, |
| 325 | }, |
| 326 | } |
| 327 | |
| 328 | // |
| 329 | // Build host fastboot_test. |
| 330 | // |
| 331 | |
| 332 | cc_test_host { |
| 333 | name: "fastboot_test", |
| 334 | defaults: ["fastboot_host_defaults"], |
| 335 | |
| 336 | srcs: [ |
| 337 | "fastboot_test.cpp", |
| 338 | "socket_mock.cpp", |
| 339 | "socket_test.cpp", |
| 340 | "tcp_test.cpp", |
| 341 | "udp_test.cpp", |
| 342 | ], |
| 343 | |
| 344 | static_libs: ["libfastboot"], |
| 345 | |
| 346 | target: { |
| 347 | windows: { |
| 348 | shared_libs: ["AdbWinApi"], |
| 349 | }, |
| 350 | windows_x86_64: { |
| 351 | // Avoid trying to build for win64 |
| 352 | enabled: false, |
| 353 | }, |
| 354 | }, |
| 355 | } |