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