Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 1 | // Copyright (C) 2021 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 | |
Bob Badour | 1464800 | 2021-03-19 04:27:32 -0700 | [diff] [blame] | 15 | package { |
| 16 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 17 | } |
| 18 | |
Yifan Hong | e71fe24 | 2021-02-22 15:00:15 -0800 | [diff] [blame] | 19 | python_binary_host { |
| 20 | name: "fastboot_gen_rand", |
| 21 | visibility: [":__subpackages__"], |
| 22 | srcs: ["fastboot_gen_rand.py"], |
| 23 | } |
| 24 | |
| 25 | genrule_defaults { |
| 26 | name: "fastboot_test_data_gen_defaults", |
| 27 | visibility: ["//system/core/fastboot"], |
| 28 | tools: [ |
| 29 | "fastboot_gen_rand", |
| 30 | ], |
| 31 | } |
| 32 | |
| 33 | // Genrules for components of test vendor boot image. |
| 34 | |
| 35 | // Fake dtb image. |
| 36 | genrule { |
| 37 | name: "fastboot_test_dtb", |
| 38 | defaults: ["fastboot_test_data_gen_defaults"], |
| 39 | out: ["test_dtb.img"], |
| 40 | cmd: "$(location fastboot_gen_rand) --seed dtb --length 1024 > $(out)", |
| 41 | } |
| 42 | |
| 43 | // Fake bootconfig image. |
| 44 | genrule { |
| 45 | name: "fastboot_test_bootconfig", |
| 46 | defaults: ["fastboot_test_data_gen_defaults"], |
| 47 | out: ["test_bootconfig.img"], |
| 48 | cmd: "$(location fastboot_gen_rand) --seed bootconfig --length 1024 > $(out)", |
| 49 | } |
| 50 | |
| 51 | // Fake vendor ramdisk with type "none". |
| 52 | genrule { |
| 53 | name: "fastboot_test_vendor_ramdisk_none", |
| 54 | defaults: ["fastboot_test_data_gen_defaults"], |
| 55 | out: ["test_vendor_ramdisk_none.img"], |
| 56 | cmd: "$(location fastboot_gen_rand) --seed vendor_ramdisk_none --length 1024 > $(out)", |
| 57 | } |
| 58 | |
| 59 | // Fake vendor ramdisk with type "platform". |
| 60 | genrule { |
| 61 | name: "fastboot_test_vendor_ramdisk_platform", |
| 62 | defaults: ["fastboot_test_data_gen_defaults"], |
| 63 | out: ["test_vendor_ramdisk_platform.img"], |
| 64 | cmd: "$(location fastboot_gen_rand) --seed vendor_ramdisk_platform --length 1024 > $(out)", |
| 65 | } |
| 66 | |
| 67 | // Fake replacement ramdisk. |
| 68 | genrule { |
| 69 | name: "fastboot_test_vendor_ramdisk_replace", |
| 70 | defaults: ["fastboot_test_data_gen_defaults"], |
| 71 | out: ["test_vendor_ramdisk_replace.img"], |
| 72 | cmd: "$(location fastboot_gen_rand) --seed replace --length 3072 > $(out)", |
| 73 | } |
| 74 | |
| 75 | // Genrules for test vendor boot images. |
| 76 | |
| 77 | fastboot_sign_test_image = "$(location avbtool) add_hash_footer --salt 00 --image $(out) " + |
| 78 | "--partition_name vendor_boot --partition_size $$(( 1 * 1024 * 1024 ))" |
| 79 | |
| 80 | genrule_defaults { |
| 81 | name: "fastboot_test_vendor_boot_gen_defaults", |
| 82 | defaults: ["fastboot_test_data_gen_defaults"], |
| 83 | tools: [ |
| 84 | "avbtool", |
| 85 | "mkbootimg", |
| 86 | ], |
| 87 | } |
| 88 | |
| 89 | genrule { |
| 90 | name: "fastboot_test_vendor_boot_v3", |
| 91 | defaults: ["fastboot_test_vendor_boot_gen_defaults"], |
| 92 | out: ["vendor_boot_v3.img"], |
| 93 | srcs: [ |
| 94 | ":fastboot_test_dtb", |
| 95 | ":fastboot_test_vendor_ramdisk_none", |
| 96 | ], |
| 97 | cmd: "$(location mkbootimg) --header_version 3 " + |
| 98 | "--vendor_ramdisk $(location :fastboot_test_vendor_ramdisk_none) " + |
| 99 | "--dtb $(location :fastboot_test_dtb) " + |
| 100 | "--vendor_boot $(out) && " + |
| 101 | fastboot_sign_test_image, |
| 102 | } |
| 103 | |
| 104 | genrule { |
| 105 | name: "fastboot_test_vendor_boot_v4_without_frag", |
| 106 | defaults: ["fastboot_test_vendor_boot_gen_defaults"], |
| 107 | out: ["vendor_boot_v4_without_frag.img"], |
| 108 | srcs: [ |
| 109 | ":fastboot_test_dtb", |
| 110 | ":fastboot_test_vendor_ramdisk_none", |
| 111 | ":fastboot_test_bootconfig", |
| 112 | ], |
| 113 | cmd: "$(location mkbootimg) --header_version 4 " + |
| 114 | "--vendor_ramdisk $(location :fastboot_test_vendor_ramdisk_none) " + |
| 115 | "--dtb $(location :fastboot_test_dtb) " + |
| 116 | "--vendor_bootconfig $(location :fastboot_test_bootconfig) " + |
| 117 | "--vendor_boot $(out) && " + |
| 118 | fastboot_sign_test_image, |
| 119 | } |
| 120 | |
| 121 | genrule { |
| 122 | name: "fastboot_test_vendor_boot_v4_with_frag", |
| 123 | defaults: ["fastboot_test_vendor_boot_gen_defaults"], |
| 124 | out: ["vendor_boot_v4_with_frag.img"], |
| 125 | srcs: [ |
| 126 | ":fastboot_test_dtb", |
| 127 | ":fastboot_test_vendor_ramdisk_none", |
| 128 | ":fastboot_test_vendor_ramdisk_platform", |
| 129 | ":fastboot_test_bootconfig", |
| 130 | ], |
| 131 | cmd: "$(location mkbootimg) --header_version 4 " + |
| 132 | "--dtb $(location :fastboot_test_dtb) " + |
| 133 | "--vendor_bootconfig $(location :fastboot_test_bootconfig) " + |
| 134 | "--ramdisk_type none --ramdisk_name none_ramdisk " + |
| 135 | "--vendor_ramdisk_fragment $(location :fastboot_test_vendor_ramdisk_none) " + |
| 136 | "--ramdisk_type platform --ramdisk_name platform_ramdisk " + |
| 137 | "--vendor_ramdisk_fragment $(location :fastboot_test_vendor_ramdisk_platform) " + |
| 138 | "--vendor_boot $(out) && " + |
| 139 | fastboot_sign_test_image, |
| 140 | } |