blob: 81e3f8a405e1763880212310f3f6d6e9456a08d5 [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",
30 "-ffunction-sections",
31 "-fstack-protector-strong",
32 "-g",
33 "-DAVB_ENABLE_DEBUG",
34 "-DAVB_COMPILATION",
35 ],
36 cppflags: [
37 "-Wnon-virtual-dtor",
38 "-fno-strict-aliasing",
39 ],
40 ldflags: [
41 "-Wl,--gc-sections",
42 "-rdynamic",
43 ],
44 target: {
45 darwin: {
46 enabled: false,
47 },
48 },
49}
50
51cc_defaults {
52 name: "avb_sources",
53 srcs: [
54 "libavb/avb_chain_partition_descriptor.c",
55 "libavb/avb_crc32.c",
56 "libavb/avb_crypto.c",
57 "libavb/avb_descriptor.c",
58 "libavb/avb_footer.c",
59 "libavb/avb_hash_descriptor.c",
60 "libavb/avb_hashtree_descriptor.c",
61 "libavb/avb_kernel_cmdline_descriptor.c",
62 "libavb/avb_property_descriptor.c",
63 "libavb/avb_rsa.c",
64 "libavb/avb_sha256.c",
65 "libavb/avb_sha512.c",
66 "libavb/avb_slot_verify.c",
67 "libavb/avb_util.c",
68 "libavb/avb_vbmeta_image.c",
69 "libavb/avb_version.c",
70 ],
71}
72
73cc_prebuilt_binary {
74 name: "avbtool",
75 srcs: ["avbtool"],
76 required: ["fec"],
77 device_supported: false,
78 host_supported: true,
Tom Cherry8d225d82017-05-12 17:00:31 -070079}
80
81// Build libavb - this is a static library that depends
82// on only libc and doesn't drag in any other dependencies.
83cc_library_static {
84 name: "libavb",
85 defaults: [
86 "avb_defaults",
87 "avb_sources",
88 ],
89 host_supported: true,
90 export_include_dirs: ["."],
91 target: {
92 android: {
93 srcs: ["libavb/avb_sysdeps_posix.c"],
94 },
95 linux: {
96 cflags: ["-fno-stack-protector"],
97 },
98 },
99}
100
101// Build libavb_user for the target - in addition to libavb, it
102// includes libavb_ab, libavb_user and also depends on libbase and
103// libfs_mgr.
104cc_library_static {
105 name: "libavb_user",
106 defaults: [
107 "avb_defaults",
108 "avb_sources",
109 ],
110 export_include_dirs: ["."],
111 shared_libs: ["libbase"],
112 static_libs: ["libfs_mgr"],
David Zeuthen37f59462017-09-20 15:02:32 -0400113 cflags: [
114 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
115 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700116 srcs: [
117 "libavb/avb_sysdeps_posix.c",
118 "libavb_ab/avb_ab_flow.c",
Bowgo Tsai84c610e2017-09-28 15:13:05 +0800119 "libavb_user/avb_ops_user.cpp",
Tom Cherry8d225d82017-05-12 17:00:31 -0700120 "libavb_user/avb_user_verity.c",
David Zeuthen0922bf82017-06-19 17:50:38 -0400121 "libavb_user/avb_user_verification.c",
Tom Cherry8d225d82017-05-12 17:00:31 -0700122 ],
123}
124
125cc_binary {
126 name: "avbctl",
127 defaults: ["avb_defaults"],
128 static_libs: [
129 "libavb_user",
130 "libfs_mgr",
131 ],
132 shared_libs: ["libbase"],
133 srcs: ["tools/avbctl/avbctl.cc"],
134}
135
136cc_library_host_static {
137 name: "libavb_ab_host",
138 defaults: ["avb_defaults"],
139 export_include_dirs: ["."],
140 cflags: [
141 "-fno-stack-protector",
David Zeuthen37f59462017-09-20 15:02:32 -0400142 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
Tom Cherry8d225d82017-05-12 17:00:31 -0700143 ],
144 srcs: ["libavb_ab/avb_ab_flow.c"],
145}
146
147cc_library_host_static {
148 name: "libavb_atx_host",
149 defaults: ["avb_defaults"],
150 export_include_dirs: ["."],
151 cflags: [
152 "-fno-stack-protector",
153 ],
154 srcs: ["libavb_atx/avb_atx_validate.c"],
155}
156
157cc_library_host_static {
158 name: "libavb_host_sysdeps",
159 defaults: ["avb_defaults"],
160 export_include_dirs: ["."],
161 srcs: ["libavb/avb_sysdeps_posix.c"],
162}
163
164cc_test_host {
165 name: "libavb_host_unittest",
166 defaults: ["avb_defaults"],
167 required: [
168 "simg2img",
169 "img2simg",
170 "avbtool",
171 ],
172 static_libs: [
173 "libavb",
174 "libavb_ab_host",
175 "libavb_atx_host",
176 "libgmock_host",
177 "libgtest_host",
178 ],
179 shared_libs: [
180 "libchrome",
181 "libcrypto",
182 ],
David Zeuthen047ecf72017-06-28 14:10:55 -0400183 cflags: [
184 "-Wno-missing-prototypes",
David Zeuthen37f59462017-09-20 15:02:32 -0400185 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
David Zeuthen047ecf72017-06-28 14:10:55 -0400186 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700187 srcs: [
188 "test/avb_ab_flow_unittest.cc",
189 "test/avb_atx_validate_unittest.cc",
190 "test/avb_slot_verify_unittest.cc",
191 "test/avb_unittest_util.cc",
192 "test/avb_util_unittest.cc",
193 "test/avb_vbmeta_image_unittest.cc",
194 "test/avbtool_unittest.cc",
195 "test/fake_avb_ops.cc",
196 "test/avb_sysdeps_posix_testing.cc",
197 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700198}
199
200cc_library_host_static {
201 name: "libavb_host_user_code_test",
202 defaults: ["avb_defaults"],
David Zeuthen37f59462017-09-20 15:02:32 -0400203 cflags: [
204 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
205 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700206 srcs: ["test/user_code_test.cc"],
207}
208
209cc_library {
210 name: "bootctrl.avb",
211 defaults: ["avb_defaults"],
212 relative_install_path: "hw",
213 static_libs: [
214 "libavb_user",
215 "libfs_mgr",
216 ],
217 shared_libs: [
218 "libbase",
219 "libcutils",
220 ],
David Zeuthen37f59462017-09-20 15:02:32 -0400221 cflags: [
222 "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
223 ],
Tom Cherry8d225d82017-05-12 17:00:31 -0700224 srcs: ["boot_control/boot_control_avb.c"],
225}