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", |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 58 | "vendor_boot_img_utils.cpp", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 59 | "fastboot_driver.cpp", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 60 | ], |
| 61 | |
| 62 | static_libs: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 63 | "libziparchive", |
| 64 | "libsparse", |
| 65 | "libutils", |
| 66 | "liblog", |
| 67 | "libz", |
| 68 | "libdiagnose_usb", |
| 69 | "libbase", |
| 70 | "libcutils", |
| 71 | "libgtest", |
| 72 | "libgtest_main", |
| 73 | "libbase", |
| 74 | "libadb_host", |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 75 | "liblp", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 76 | ], |
| 77 | |
| 78 | header_libs: [ |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 79 | "avb_headers", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 80 | "bootimg_headers", |
Yifan Hong | 17d469b | 2021-02-18 15:15:46 -0800 | [diff] [blame] | 81 | "libstorage_literals_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 82 | ], |
| 83 | |
| 84 | export_header_lib_headers: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 85 | "bootimg_headers", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 86 | ], |
| 87 | |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 88 | target: { |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 89 | linux: { |
| 90 | srcs: ["usb_linux.cpp"], |
| 91 | }, |
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 | darwin: { |
| 94 | srcs: ["usb_osx.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 95 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 96 | host_ldlibs: [ |
| 97 | "-framework CoreFoundation", |
| 98 | "-framework IOKit", |
| 99 | ], |
| 100 | }, |
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 | windows: { |
| 103 | srcs: ["usb_windows.cpp"], |
Aaron Wisner | a5ad20a | 2018-08-24 09:59:50 -0500 | [diff] [blame] | 104 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 105 | host_ldlibs: [ |
| 106 | "-lws2_32", |
| 107 | ], |
| 108 | }, |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 109 | }, |
| 110 | |
| 111 | cflags: [ |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 112 | "-Wall", |
| 113 | "-Wextra", |
| 114 | "-Werror", |
| 115 | "-Wunreachable-code", |
Aaron Wisner | db51120 | 2018-06-26 15:38:35 -0500 | [diff] [blame] | 116 | ], |
| 117 | |
| 118 | export_include_dirs: ["."], |
| 119 | |
| 120 | } |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 121 | |
| 122 | cc_defaults { |
| 123 | name: "fastboot_defaults", |
| 124 | |
| 125 | cflags: [ |
| 126 | "-Wall", |
| 127 | "-Wextra", |
| 128 | "-Werror", |
| 129 | "-Wvla", |
Yifan Hong | 07e947f | 2021-03-22 19:21:34 -0700 | [diff] [blame] | 130 | "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 131 | ], |
| 132 | rtti: true, |
| 133 | |
| 134 | clang_cflags: [ |
| 135 | "-Wthread-safety", |
| 136 | ], |
| 137 | } |
| 138 | |
| 139 | cc_binary { |
| 140 | name: "fastbootd", |
| 141 | defaults: ["fastboot_defaults"], |
| 142 | |
| 143 | recovery: true, |
| 144 | |
Yifan Hong | b299cb7 | 2021-02-17 13:44:49 -0800 | [diff] [blame] | 145 | product_variables: { |
| 146 | debuggable: { |
| 147 | cppflags: ["-DFB_ENABLE_FETCH"], |
| 148 | }, |
| 149 | }, |
| 150 | |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 151 | srcs: [ |
| 152 | "device/commands.cpp", |
| 153 | "device/fastboot_device.cpp", |
David Anderson | 12211d1 | 2018-07-24 15:21:20 -0700 | [diff] [blame] | 154 | "device/flashing.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 155 | "device/main.cpp", |
Josh Gao | 0871824 | 2020-03-27 18:09:56 -0700 | [diff] [blame] | 156 | "device/usb.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 157 | "device/usb_client.cpp", |
Hongguang Chen | 1e23928 | 2020-04-22 14:25:45 -0700 | [diff] [blame] | 158 | "device/tcp_client.cpp", |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 159 | "device/utility.cpp", |
| 160 | "device/variables.cpp", |
Hongguang Chen | 1e23928 | 2020-04-22 14:25:45 -0700 | [diff] [blame] | 161 | "socket.cpp", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 162 | ], |
| 163 | |
| 164 | shared_libs: [ |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 165 | "android.hardware.boot@1.0", |
David Anderson | ab8f466 | 2019-10-21 16:45:59 -0700 | [diff] [blame] | 166 | "android.hardware.boot@1.1", |
josephjang | 2906975 | 2020-09-23 16:28:03 +0800 | [diff] [blame] | 167 | "android.hardware.fastboot@1.1", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 168 | "android.hardware.health@2.0", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 169 | "libasyncio", |
| 170 | "libbase", |
| 171 | "libbootloader_message", |
| 172 | "libcutils", |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 173 | "libext2_uuid", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 174 | "libext4_utils", |
| 175 | "libfs_mgr", |
David Anderson | 1d504e3 | 2019-01-15 14:38:20 -0800 | [diff] [blame] | 176 | "libgsi", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 177 | "libhidlbase", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 178 | "liblog", |
David Anderson | 88ef0b1 | 2018-08-09 10:40:00 -0700 | [diff] [blame] | 179 | "liblp", |
David Anderson | 220ddb1 | 2019-10-31 18:02:41 -0700 | [diff] [blame] | 180 | "libprotobuf-cpp-lite", |
Tao Bao | b71eedf | 2018-08-06 19:13:38 -0700 | [diff] [blame] | 181 | "libsparse", |
| 182 | "libutils", |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 183 | ], |
| 184 | |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 185 | static_libs: [ |
David Anderson | 0b903f9 | 2021-04-07 21:43:03 -0700 | [diff] [blame] | 186 | "libc++fs", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 187 | "libhealthhalutils", |
David Anderson | aca0bea | 2020-09-21 16:34:25 -0700 | [diff] [blame] | 188 | "libsnapshot_cow", |
David Anderson | 220ddb1 | 2019-10-31 18:02:41 -0700 | [diff] [blame] | 189 | "libsnapshot_nobinder", |
Yifan Hong | 66f0115 | 2020-04-16 11:05:16 -0700 | [diff] [blame] | 190 | "update_metadata-protos", |
Hridya Valsaraju | 47658ca | 2018-09-28 11:41:22 -0700 | [diff] [blame] | 191 | ], |
Yifan Hong | 0e13bba | 2019-08-29 16:29:22 -0700 | [diff] [blame] | 192 | |
| 193 | header_libs: [ |
Steve Muckle | a9b3443 | 2020-05-12 16:21:41 -0700 | [diff] [blame] | 194 | "avb_headers", |
Elliott Hughes | 02a8324 | 2021-04-20 15:22:02 -0700 | [diff] [blame^] | 195 | "libgtest_prod_headers", |
Yifan Hong | 0e13bba | 2019-08-29 16:29:22 -0700 | [diff] [blame] | 196 | "libsnapshot_headers", |
Yifan Hong | a4eb475 | 2021-02-16 19:37:21 -0800 | [diff] [blame] | 197 | "libstorage_literals_headers", |
| 198 | ], |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 199 | } |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 200 | |
| 201 | cc_defaults { |
| 202 | name: "fastboot_host_defaults", |
| 203 | |
| 204 | use_version_lib: true, |
| 205 | |
| 206 | cflags: [ |
| 207 | "-Wall", |
| 208 | "-Wextra", |
| 209 | "-Werror", |
| 210 | "-Wunreachable-code", |
Yifan Hong | 58532df | 2021-03-22 16:39:13 -0700 | [diff] [blame] | 211 | "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION", |
Yifan Hong | c871500 | 2021-03-23 10:27:01 -0700 | [diff] [blame] | 212 | "-D_FILE_OFFSET_BITS=64" |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 213 | ], |
| 214 | |
| 215 | target: { |
| 216 | darwin: { |
| 217 | cflags: ["-Wno-unused-parameter"], |
| 218 | host_ldlibs: [ |
| 219 | "-lpthread", |
| 220 | "-framework CoreFoundation", |
| 221 | "-framework IOKit", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 222 | ], |
| 223 | }, |
| 224 | windows: { |
| 225 | enabled: true, |
| 226 | |
| 227 | host_ldlibs: ["-lws2_32"], |
| 228 | }, |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 229 | not_windows: { |
| 230 | static_libs: [ |
| 231 | "libext4_utils", |
| 232 | ], |
| 233 | }, |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 234 | }, |
| 235 | |
| 236 | stl: "libc++_static", |
| 237 | |
| 238 | // Don't add anything here, we don't want additional shared dependencies |
| 239 | // on the host fastboot tool, and shared libraries that link against libc++ |
| 240 | // will violate ODR. |
| 241 | shared_libs: [], |
| 242 | |
Chin-Ting Kuo | df6a780 | 2019-09-16 11:23:55 +0800 | [diff] [blame] | 243 | header_libs: [ |
| 244 | "avb_headers", |
| 245 | "bootimg_headers", |
| 246 | ], |
| 247 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 248 | static_libs: [ |
| 249 | "libziparchive", |
| 250 | "libsparse", |
| 251 | "libutils", |
| 252 | "liblog", |
| 253 | "libz", |
| 254 | "libdiagnose_usb", |
| 255 | "libbase", |
| 256 | "libcutils", |
| 257 | "libgtest_host", |
David Anderson | 8956964 | 2018-11-16 15:53:35 -0800 | [diff] [blame] | 258 | "liblp", |
| 259 | "libcrypto", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 260 | ], |
| 261 | } |
| 262 | |
| 263 | // |
| 264 | // Build host libfastboot. |
| 265 | // |
| 266 | |
| 267 | cc_library_host_static { |
| 268 | name: "libfastboot", |
| 269 | defaults: ["fastboot_host_defaults"], |
| 270 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 271 | srcs: [ |
| 272 | "bootimg_utils.cpp", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 273 | "fastboot.cpp", |
| 274 | "fs.cpp", |
| 275 | "socket.cpp", |
| 276 | "tcp.cpp", |
| 277 | "udp.cpp", |
| 278 | "util.cpp", |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 279 | "vendor_boot_img_utils.cpp", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 280 | "fastboot_driver.cpp", |
| 281 | ], |
| 282 | |
| 283 | // Only version the final binaries |
| 284 | use_version_lib: false, |
| 285 | static_libs: ["libbuildversion"], |
Yifan Hong | 17d469b | 2021-02-18 15:15:46 -0800 | [diff] [blame] | 286 | header_libs: [ |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 287 | "avb_headers", |
Yifan Hong | 17d469b | 2021-02-18 15:15:46 -0800 | [diff] [blame] | 288 | "libstorage_literals_headers", |
| 289 | ], |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 290 | |
| 291 | generated_headers: ["platform_tools_version"], |
| 292 | |
Chih-Hung Hsieh | 84006f5 | 2021-02-19 18:30:29 -0800 | [diff] [blame] | 293 | tidy_flags: [ |
| 294 | // DO NOT add quotes around header-filter flag regex argument, |
| 295 | // because build/soong will add quotes around the whole flag. |
| 296 | "-header-filter=(system/core/fastboot/|development/host/windows/usb/api/)", |
| 297 | ], |
| 298 | |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 299 | target: { |
| 300 | windows: { |
| 301 | srcs: ["usb_windows.cpp"], |
| 302 | |
| 303 | include_dirs: ["development/host/windows/usb/api"], |
| 304 | }, |
| 305 | darwin: { |
| 306 | srcs: ["usb_osx.cpp"], |
| 307 | }, |
Jiyong Park | fd89028 | 2020-08-20 18:04:01 +0900 | [diff] [blame] | 308 | linux: { |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 309 | srcs: ["usb_linux.cpp"], |
| 310 | }, |
| 311 | }, |
| 312 | } |
| 313 | |
| 314 | // |
| 315 | // Build host fastboot / fastboot.exe |
| 316 | // |
| 317 | |
| 318 | cc_binary_host { |
| 319 | name: "fastboot", |
| 320 | defaults: ["fastboot_host_defaults"], |
| 321 | |
| 322 | srcs: ["main.cpp"], |
| 323 | static_libs: ["libfastboot"], |
| 324 | |
| 325 | required: [ |
| 326 | "mke2fs", |
| 327 | "make_f2fs", |
Jaegeuk Kim | a389610 | 2020-07-17 20:30:41 -0700 | [diff] [blame] | 328 | "make_f2fs_casefold", |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 329 | ], |
Dan Willemsen | 3f439a7 | 2018-11-19 19:11:35 -0800 | [diff] [blame] | 330 | dist: { |
| 331 | targets: [ |
| 332 | "dist_files", |
| 333 | "sdk", |
| 334 | "win_sdk", |
| 335 | ], |
| 336 | }, |
Dan Willemsen | ab971b5 | 2018-08-29 14:58:02 -0700 | [diff] [blame] | 337 | |
| 338 | target: { |
| 339 | not_windows: { |
| 340 | required: [ |
| 341 | "e2fsdroid", |
| 342 | "mke2fs.conf", |
| 343 | "sload_f2fs", |
| 344 | ], |
| 345 | }, |
| 346 | windows: { |
| 347 | required: ["AdbWinUsbApi"], |
| 348 | shared_libs: ["AdbWinApi"], |
| 349 | }, |
| 350 | }, |
| 351 | } |
| 352 | |
| 353 | // |
| 354 | // Build host fastboot_test. |
| 355 | // |
| 356 | |
| 357 | cc_test_host { |
| 358 | name: "fastboot_test", |
| 359 | defaults: ["fastboot_host_defaults"], |
| 360 | |
| 361 | srcs: [ |
| 362 | "fastboot_test.cpp", |
| 363 | "socket_mock.cpp", |
| 364 | "socket_test.cpp", |
| 365 | "tcp_test.cpp", |
| 366 | "udp_test.cpp", |
| 367 | ], |
| 368 | |
| 369 | static_libs: ["libfastboot"], |
| 370 | |
| 371 | target: { |
| 372 | windows: { |
| 373 | shared_libs: ["AdbWinApi"], |
| 374 | }, |
| 375 | windows_x86_64: { |
| 376 | // Avoid trying to build for win64 |
| 377 | enabled: false, |
| 378 | }, |
| 379 | }, |
| 380 | } |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 381 | |
| 382 | cc_test_host { |
| 383 | name: "fastboot_vendor_boot_img_utils_test", |
| 384 | srcs: ["vendor_boot_img_utils_test.cpp"], |
| 385 | static_libs: [ |
| 386 | "libbase", |
| 387 | "libc++fs", |
| 388 | "libfastboot", |
| 389 | "libgmock", |
| 390 | "liblog", |
| 391 | ], |
| 392 | header_libs: [ |
| 393 | "avb_headers", |
| 394 | "bootimg_headers", |
| 395 | ], |
| 396 | cflags: [ |
| 397 | "-Wall", |
| 398 | "-Werror", |
| 399 | ], |
| 400 | data: [ |
| 401 | ":fastboot_test_dtb", |
| 402 | ":fastboot_test_bootconfig", |
| 403 | ":fastboot_test_vendor_ramdisk_none", |
| 404 | ":fastboot_test_vendor_ramdisk_platform", |
| 405 | ":fastboot_test_vendor_ramdisk_replace", |
| 406 | ":fastboot_test_vendor_boot_v3", |
| 407 | ":fastboot_test_vendor_boot_v4_without_frag", |
| 408 | ":fastboot_test_vendor_boot_v4_with_frag" |
| 409 | ], |
| 410 | } |