blob: 467596597ec2d3e459143a2322f52fc1d4114206 [file] [log] [blame]
Tom Cherry8d225d82017-05-12 17:00:31 -07001//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "avb_defaults",
19 cflags: [
20 "-D_FILE_OFFSET_BITS=64",
21 "-D_POSIX_C_SOURCE=199309L",
22 "-Wa,--noexecstack",
23 "-Werror",
24 "-Wall",
25 "-Wextra",
26 "-Wformat=2",
David Zeuthen047ecf72017-06-28 14:10:55 -040027 "-Wmissing-prototypes",
Tom Cherry8d225d82017-05-12 17:00:31 -070028 "-Wno-psabi",
29 "-Wno-unused-parameter",
Yi Konged46d642018-01-03 11:52:56 -080030 "-Wno-format",
Tom Cherry8d225d82017-05-12 17:00:31 -070031 "-ffunction-sections",
32 "-fstack-protector-strong",
33 "-g",
34 "-DAVB_ENABLE_DEBUG",
35 "-DAVB_COMPILATION",
36 ],
37 cppflags: [
38 "-Wnon-virtual-dtor",
39 "-fno-strict-aliasing",
40 ],
41 ldflags: [
42 "-Wl,--gc-sections",
43 "-rdynamic",
44 ],
45 target: {
46 darwin: {
47 enabled: false,
48 },
49 },
50}
51
52cc_defaults {
53 name: "avb_sources",
54 srcs: [
55 "libavb/avb_chain_partition_descriptor.c",
Lonnie Liu97740e52017-11-09 11:16:15 -080056 "libavb/avb_cmdline.c",
Tom Cherry8d225d82017-05-12 17:00:31 -070057 "libavb/avb_crc32.c",
58 "libavb/avb_crypto.c",
59 "libavb/avb_descriptor.c",
60 "libavb/avb_footer.c",
61 "libavb/avb_hash_descriptor.c",
62 "libavb/avb_hashtree_descriptor.c",
63 "libavb/avb_kernel_cmdline_descriptor.c",
64 "libavb/avb_property_descriptor.c",
65 "libavb/avb_rsa.c",
66 "libavb/avb_sha256.c",
67 "libavb/avb_sha512.c",
68 "libavb/avb_slot_verify.c",
69 "libavb/avb_util.c",
70 "libavb/avb_vbmeta_image.c",
71 "libavb/avb_version.c",
72 ],
73}
74
75cc_prebuilt_binary {
76 name: "avbtool",
77 srcs: ["avbtool"],
78 required: ["fec"],
79 device_supported: false,
80 host_supported: true,
Tom Cherry8d225d82017-05-12 17:00:31 -070081}
82
83// Build libavb - this is a static library that depends
84// on only libc and doesn't drag in any other dependencies.
85cc_library_static {
86 name: "libavb",
87 defaults: [
88 "avb_defaults",
89 "avb_sources",
90 ],
91 host_supported: true,
92 export_include_dirs: ["."],
93 target: {
94 android: {
95 srcs: ["libavb/avb_sysdeps_posix.c"],
96 },
Dan Willemsen34ec1232017-10-02 10:41:07 -070097 linux_glibc: {
Tom Cherry8d225d82017-05-12 17:00:31 -070098 cflags: ["-fno-stack-protector"],
99 },
100 },
101}
102
103// Build libavb_user for the target - in addition to libavb, it
104// includes libavb_ab, libavb_user and also depends on libbase and
105// libfs_mgr.
106cc_library_static {
107 name: "libavb_user",
108 defaults: [
109 "avb_defaults",
110 "avb_sources",
111 ],
112 export_include_dirs: ["."],
113 shared_libs: ["libbase"],
114 static_libs: ["libfs_mgr"],
David Zeuthen37f59462017-09-20 15:02:32 -0400115 cflags: [
116 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
117 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700118 srcs: [
119 "libavb/avb_sysdeps_posix.c",
120 "libavb_ab/avb_ab_flow.c",
Bowgo Tsai84c610e2017-09-28 15:13:05 +0800121 "libavb_user/avb_ops_user.cpp",
Tom Cherry8d225d82017-05-12 17:00:31 -0700122 "libavb_user/avb_user_verity.c",
David Zeuthen0922bf82017-06-19 17:50:38 -0400123 "libavb_user/avb_user_verification.c",
Tom Cherry8d225d82017-05-12 17:00:31 -0700124 ],
125}
126
127cc_binary {
128 name: "avbctl",
129 defaults: ["avb_defaults"],
130 static_libs: [
131 "libavb_user",
132 "libfs_mgr",
133 ],
134 shared_libs: ["libbase"],
135 srcs: ["tools/avbctl/avbctl.cc"],
136}
137
138cc_library_host_static {
139 name: "libavb_ab_host",
140 defaults: ["avb_defaults"],
141 export_include_dirs: ["."],
142 cflags: [
143 "-fno-stack-protector",
David Zeuthen37f59462017-09-20 15:02:32 -0400144 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
Tom Cherry8d225d82017-05-12 17:00:31 -0700145 ],
146 srcs: ["libavb_ab/avb_ab_flow.c"],
147}
148
149cc_library_host_static {
150 name: "libavb_atx_host",
151 defaults: ["avb_defaults"],
152 export_include_dirs: ["."],
153 cflags: [
154 "-fno-stack-protector",
155 ],
156 srcs: ["libavb_atx/avb_atx_validate.c"],
157}
158
159cc_library_host_static {
160 name: "libavb_host_sysdeps",
161 defaults: ["avb_defaults"],
162 export_include_dirs: ["."],
163 srcs: ["libavb/avb_sysdeps_posix.c"],
164}
165
Darren Krahn8160f362017-10-05 22:11:02 -0700166cc_library_host_static {
167 name: "libavb_things_example",
168 defaults: ["avb_defaults"],
169 export_include_dirs: ["."],
170 srcs: ["examples/things/avb_atx_slot_verify.c"],
171}
172
Tom Cherry8d225d82017-05-12 17:00:31 -0700173cc_test_host {
174 name: "libavb_host_unittest",
175 defaults: ["avb_defaults"],
176 required: [
177 "simg2img",
178 "img2simg",
179 "avbtool",
180 ],
181 static_libs: [
182 "libavb",
183 "libavb_ab_host",
184 "libavb_atx_host",
Darren Krahn8160f362017-10-05 22:11:02 -0700185 "libavb_things_example",
Tom Cherry8d225d82017-05-12 17:00:31 -0700186 "libgmock_host",
187 "libgtest_host",
188 ],
189 shared_libs: [
190 "libchrome",
191 "libcrypto",
192 ],
David Zeuthen047ecf72017-06-28 14:10:55 -0400193 cflags: [
194 "-Wno-missing-prototypes",
David Zeuthen37f59462017-09-20 15:02:32 -0400195 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
David Zeuthen047ecf72017-06-28 14:10:55 -0400196 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700197 srcs: [
198 "test/avb_ab_flow_unittest.cc",
199 "test/avb_atx_validate_unittest.cc",
Darren Krahn8160f362017-10-05 22:11:02 -0700200 "test/avb_atx_slot_verify_unittest.cc",
Tom Cherry8d225d82017-05-12 17:00:31 -0700201 "test/avb_slot_verify_unittest.cc",
202 "test/avb_unittest_util.cc",
203 "test/avb_util_unittest.cc",
204 "test/avb_vbmeta_image_unittest.cc",
205 "test/avbtool_unittest.cc",
206 "test/fake_avb_ops.cc",
207 "test/avb_sysdeps_posix_testing.cc",
208 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700209}
210
211cc_library_host_static {
212 name: "libavb_host_user_code_test",
213 defaults: ["avb_defaults"],
David Zeuthen37f59462017-09-20 15:02:32 -0400214 cflags: [
215 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
216 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700217 srcs: ["test/user_code_test.cc"],
218}
219
220cc_library {
221 name: "bootctrl.avb",
222 defaults: ["avb_defaults"],
223 relative_install_path: "hw",
224 static_libs: [
225 "libavb_user",
226 "libfs_mgr",
227 ],
228 shared_libs: [
229 "libbase",
230 "libcutils",
231 ],
David Zeuthen37f59462017-09-20 15:02:32 -0400232 cflags: [
233 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
234 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700235 srcs: ["boot_control/boot_control_avb.c"],
236}