• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
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)
17package {
18    default_applicable_licenses: [
19        "system_core_fastboot_license",
20        "Android-Apache-2.0",
21    ],
22}
23
24// Added automatically by a large-scale-change that took the approach of
25// 'apply every license found to every target'. While this makes sure we respect
26// every license restriction, it may not be entirely correct.
27//
28// e.g. GPL in an MIT project might only apply to the contrib/ directory.
29//
30// Please consider splitting the single license below into multiple licenses,
31// taking care not to lose any license_kind information, and overriding the
32// default license using the 'licenses: [...]' property on targets as needed.
33//
34// For unused files, consider creating a 'fileGroup' with "//visibility:private"
35// to attach the license to, and including a comment whether the files may be
36// used in the current project.
37// See: http://go/android-license-faq
38license {
39    name: "system_core_fastboot_license",
40    visibility: [":__subpackages__"],
41    license_kinds: [
42        "SPDX-license-identifier-BSD",
43    ],
44    license_text: ["LICENSE"],
45}
46
47cc_library_host_static {
48    name: "libfastboot2",
49
50    //host_supported: true,
51
52    compile_multilib: "first",
53    srcs: [
54        "bootimg_utils.cpp",
55        "fs.cpp",
56        "socket.cpp",
57        "tcp.cpp",
58        "udp.cpp",
59        "util.cpp",
60        "vendor_boot_img_utils.cpp",
61        "fastboot_driver.cpp",
62    ],
63
64    static_libs: [
65        "libziparchive",
66        "libsparse",
67        "libutils",
68        "liblog",
69        "libz",
70        "libdiagnose_usb",
71        "libbase",
72        "libcutils",
73        "libgtest",
74        "libgtest_main",
75        "libbase",
76        "libadb_host",
77        "liblp",
78    ],
79
80    header_libs: [
81        "avb_headers",
82        "bootimg_headers",
83        "libstorage_literals_headers",
84    ],
85
86    export_header_lib_headers: [
87        "bootimg_headers",
88    ],
89
90    target: {
91        linux: {
92            srcs: ["usb_linux.cpp"],
93        },
94
95        darwin: {
96            srcs: ["usb_osx.cpp"],
97
98            host_ldlibs: [
99                "-framework CoreFoundation",
100                "-framework IOKit",
101            ],
102        },
103
104        windows: {
105            srcs: ["usb_windows.cpp"],
106
107            host_ldlibs: [
108                "-lws2_32",
109            ],
110        },
111    },
112
113    cflags: [
114        "-Wall",
115        "-Wextra",
116        "-Werror",
117        "-Wunreachable-code",
118    ],
119
120    export_include_dirs: ["."],
121
122}
123
124cc_defaults {
125    name: "fastboot_defaults",
126
127    cflags: [
128        "-Wall",
129        "-Wextra",
130        "-Werror",
131        "-Wvla",
132        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
133        "-Wthread-safety",
134    ],
135    rtti: true,
136
137}
138
139cc_binary {
140    name: "fastbootd",
141    defaults: ["fastboot_defaults"],
142
143    recovery: true,
144
145    product_variables: {
146        debuggable: {
147            cppflags: ["-DFB_ENABLE_FETCH"],
148        },
149    },
150
151    srcs: [
152        "device/commands.cpp",
153        "device/fastboot_device.cpp",
154        "device/flashing.cpp",
155        "device/main.cpp",
156        "device/usb.cpp",
157        "device/usb_iouring.cpp",
158        "device/usb_client.cpp",
159        "device/tcp_client.cpp",
160        "device/utility.cpp",
161        "device/variables.cpp",
162        "socket.cpp",
163    ],
164
165    shared_libs: [
166        "android.hardware.boot@1.0",
167        "android.hardware.boot@1.1",
168        "android.hardware.boot-V1-ndk",
169        "libboot_control_client",
170        "android.hardware.fastboot@1.1",
171        "android.hardware.fastboot-V1-ndk",
172        "android.hardware.health@2.0",
173        "android.hardware.health-V4-ndk",
174        "libasyncio",
175        "libbase",
176        "libbinder_ndk",
177        "libbootloader_message",
178        "libcutils",
179        "libext2_uuid",
180        "libext4_utils",
181        "libfs_mgr",
182        "libgsi",
183        "libhidlbase",
184        "liblog",
185        "liblp",
186        "libprotobuf-cpp-lite",
187        "libsparse",
188        "libutils",
189        "libselinux",
190    ],
191
192    static_libs: [
193        "android.hardware.health-translate-ndk",
194        "libhealthhalutils",
195        "libhealthshim",
196        "libfastbootshim",
197        "libsnapshot_cow",
198        "liblz4",
199        "libzstd",
200        "libsnapshot_nobinder",
201        "update_metadata-protos",
202        "liburing",
203    ],
204
205    header_libs: [
206        "avb_headers",
207        "libgtest_prod_headers",
208        "libsnapshot_headers",
209        "libstorage_literals_headers",
210    ],
211}
212
213cc_defaults {
214    name: "fastboot_host_defaults",
215
216    use_version_lib: true,
217
218    cflags: [
219        "-Wall",
220        "-Wextra",
221        "-Werror",
222        "-Wunreachable-code",
223        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
224        "-D_FILE_OFFSET_BITS=64",
225    ],
226
227    target: {
228        darwin: {
229            cflags: ["-Wno-unused-parameter"],
230            host_ldlibs: [
231                "-lpthread",
232                "-framework CoreFoundation",
233                "-framework IOKit",
234            ],
235        },
236        windows: {
237            enabled: true,
238
239            host_ldlibs: ["-lws2_32"],
240        },
241        not_windows: {
242            static_libs: [
243                "libext4_utils",
244            ],
245        },
246    },
247
248    stl: "libc++_static",
249
250    // Don't add anything here, we don't want additional shared dependencies
251    // on the host fastboot tool, and shared libraries that link against libc++
252    // will violate ODR.
253    shared_libs: [],
254
255    header_libs: [
256        "avb_headers",
257        "bootimg_headers",
258    ],
259
260    static_libs: [
261        "libziparchive",
262        "libsparse",
263        "libutils",
264        "liblog",
265        "liblz4",
266        "libz",
267        "libdiagnose_usb",
268        "libbase",
269        "libcutils",
270        "libgtest_host",
271        "liblp",
272        "libcrypto",
273    ],
274}
275
276//
277// Build host libfastboot.
278//
279
280cc_library_host_static {
281    name: "libfastboot",
282    defaults: ["fastboot_host_defaults"],
283
284    srcs: [
285        "bootimg_utils.cpp",
286        "fastboot_driver.cpp",
287        "fastboot.cpp",
288        "filesystem.cpp",
289        "fs.cpp",
290        "socket.cpp",
291        "storage.cpp",
292        "super_flash_helper.cpp",
293        "tcp.cpp",
294        "udp.cpp",
295        "util.cpp",
296        "vendor_boot_img_utils.cpp",
297        "task.cpp",
298    ],
299
300    // Only version the final binaries
301    use_version_lib: false,
302    static_libs: ["libbuildversion"],
303    header_libs: [
304        "avb_headers",
305        "libstorage_literals_headers",
306    ],
307
308    generated_headers: ["platform_tools_version"],
309
310    target: {
311        windows: {
312            srcs: ["usb_windows.cpp"],
313
314            include_dirs: ["development/host/windows/usb/api"],
315        },
316        darwin: {
317            srcs: ["usb_osx.cpp"],
318        },
319        linux: {
320            srcs: ["usb_linux.cpp"],
321        },
322    },
323}
324
325//
326// Build host fastboot / fastboot.exe
327//
328
329cc_binary_host {
330    name: "fastboot",
331    defaults: ["fastboot_host_defaults"],
332
333    srcs: ["main.cpp"],
334    static_libs: ["libfastboot"],
335
336    required: [
337        "mke2fs",
338        "make_f2fs",
339        "make_f2fs_casefold",
340    ],
341    dist: {
342        targets: [
343            "dist_files",
344            "sdk",
345            "sdk-repo-platform-tools",
346            "sdk_repo",
347            "win_sdk",
348        ],
349    },
350
351    target: {
352        not_windows: {
353            required: [
354                "mke2fs.conf",
355            ],
356        },
357        windows: {
358            required: ["AdbWinUsbApi"],
359            shared_libs: ["AdbWinApi"],
360        },
361    },
362}
363
364//
365// Build host fastboot_test.
366//
367
368cc_test_host {
369    name: "fastboot_test",
370    defaults: ["fastboot_host_defaults"],
371
372    srcs: [
373        "fastboot_driver_test.cpp",
374        "fastboot_test.cpp",
375        "socket_mock.cpp",
376        "socket_test.cpp",
377        "super_flash_helper_test.cpp",
378        "task_test.cpp",
379        "tcp_test.cpp",
380        "udp_test.cpp",
381    ],
382
383    static_libs: [
384        "libfastboot",
385        "libgmock",
386    ],
387
388    target: {
389        windows: {
390            shared_libs: ["AdbWinApi"],
391        },
392        windows_x86_64: {
393            // Avoid trying to build for win64
394            enabled: false,
395        },
396    },
397
398    test_suites: ["general-tests"],
399
400    data: [
401        "testdata/super.img",
402        "testdata/super_empty.img",
403        "testdata/system.img",
404    ],
405}
406
407cc_test_host {
408    name: "fastboot_vendor_boot_img_utils_test",
409    srcs: ["vendor_boot_img_utils_test.cpp"],
410    static_libs: [
411        "libbase",
412        "libfastboot",
413        "libgmock",
414        "liblog",
415    ],
416    header_libs: [
417        "avb_headers",
418        "bootimg_headers",
419    ],
420    cflags: [
421        "-Wall",
422        "-Werror",
423    ],
424    data: [
425        ":fastboot_test_dtb",
426        ":fastboot_test_dtb_replace",
427        ":fastboot_test_bootconfig",
428        ":fastboot_test_vendor_ramdisk_none",
429        ":fastboot_test_vendor_ramdisk_platform",
430        ":fastboot_test_vendor_ramdisk_replace",
431        ":fastboot_test_vendor_boot_v3",
432        ":fastboot_test_vendor_boot_v4_without_frag",
433        ":fastboot_test_vendor_boot_v4_with_frag",
434    ],
435}
436
437cc_library_headers {
438    name: "fastboot_headers",
439    host_supported: true,
440    export_include_dirs: ["."],
441}
442
443python_test_host {
444    name: "fastboot_integration_test",
445    main: "test_fastboot.py",
446    srcs: ["test_fastboot.py"],
447    data: [":fastboot"],
448    test_config: "fastboot_integration_test.xml",
449    test_options: {
450        unit_test: false,
451    },
452}
453