• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2017-2020 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
17package {
18    default_applicable_licenses: ["external_avb_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34// See: http://go/android-license-faq
35license {
36    name: "external_avb_license",
37    visibility: [":__subpackages__"],
38    license_kinds: [
39        "SPDX-license-identifier-Apache-2.0",
40        "SPDX-license-identifier-BSD",
41        "SPDX-license-identifier-MIT",
42    ],
43    license_text: [
44        "LICENSE",
45    ],
46}
47
48subdirs = [
49    "test",
50    "tools",
51]
52
53cc_defaults {
54    name: "avb_defaults",
55    cflags: [
56        "-D_FILE_OFFSET_BITS=64",
57        "-D_POSIX_C_SOURCE=199309L",
58        "-Wa,--noexecstack",
59        "-Werror",
60        "-Wall",
61        "-Wextra",
62        "-Wformat=2",
63        "-Wmissing-prototypes",
64        "-Wno-psabi",
65        "-Wno-unused-parameter",
66        "-Wno-format",
67        "-ffunction-sections",
68        "-fstack-protector-strong",
69        "-g",
70        "-DAVB_ENABLE_DEBUG",
71        "-DAVB_COMPILATION",
72    ],
73    cppflags: [
74        "-Wnon-virtual-dtor",
75        "-fno-strict-aliasing",
76    ],
77    ldflags: [
78        "-Wl,--gc-sections",
79        "-rdynamic",
80    ],
81    target: {
82        darwin: {
83            enabled: false,
84        },
85    },
86}
87
88cc_defaults {
89    name: "avb_sources",
90    srcs: [
91        "libavb/avb_chain_partition_descriptor.c",
92        "libavb/avb_cmdline.c",
93        "libavb/avb_crc32.c",
94        "libavb/avb_crypto.c",
95        "libavb/avb_descriptor.c",
96        "libavb/avb_footer.c",
97        "libavb/avb_hash_descriptor.c",
98        "libavb/avb_hashtree_descriptor.c",
99        "libavb/avb_kernel_cmdline_descriptor.c",
100        "libavb/avb_property_descriptor.c",
101        "libavb/avb_rsa.c",
102        "libavb/avb_slot_verify.c",
103        "libavb/avb_util.c",
104        "libavb/avb_vbmeta_image.c",
105        "libavb/avb_version.c",
106    ],
107}
108
109cc_defaults {
110    name: "avb_crypto_ops_impl_boringssl",
111    srcs: [
112        "libavb/boringssl/sha.c",
113    ],
114    local_include_dirs: [
115        "libavb/boringssl",
116    ],
117    shared_libs: [
118        "libcrypto",
119    ],
120}
121
122cc_defaults {
123    name: "avb_crypto_ops_impl_sha",
124    srcs: [
125        "libavb/sha/sha256_impl.c",
126        "libavb/sha/sha512_impl.c",
127    ],
128    local_include_dirs: [
129        "libavb/sha",
130    ],
131}
132
133python_binary_host {
134    name: "avbtool",
135    srcs: ["avbtool.py"],
136    main: "avbtool.py",
137    required: ["fec"],
138    version: {
139        py2: {
140            enabled: false,
141        },
142        py3: {
143            enabled: true,
144            embedded_launcher: true,
145        },
146    },
147    compile_multilib: "first",
148}
149
150// Build libavb - this is a static library that depends
151// on only libc and libcrypto, but no other dependencies.
152cc_library_static {
153    name: "libavb",
154    defaults: [
155        "avb_defaults",
156        "avb_sources",
157        "avb_crypto_ops_impl_boringssl",
158    ],
159    host_supported: true,
160    ramdisk_available: true,
161    vendor_ramdisk_available: true,
162    recovery_available: true,
163    header_libs: [
164        "avb_headers",
165    ],
166    export_header_lib_headers: ["avb_headers"],
167    target: {
168        linux: {
169            srcs: ["libavb/avb_sysdeps_posix.c"],
170        },
171        host_linux: {
172            cflags: ["-fno-stack-protector"],
173        },
174    },
175}
176
177// Build libavb_user for the target - in addition to libavb, it
178// includes libavb_ab, libavb_user and also depends on libbase and
179// libfs_mgr.
180cc_library_static {
181    name: "libavb_user",
182    defaults: [
183        "avb_defaults",
184        "avb_sources",
185        "avb_crypto_ops_impl_boringssl",
186    ],
187    recovery_available: true,
188    header_libs: [
189        "avb_headers",
190    ],
191    export_header_lib_headers: ["avb_headers"],
192    shared_libs: ["libbase"],
193    static_libs: ["libfs_mgr"],
194    cflags: [
195        "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
196    ],
197    srcs: [
198        "libavb/avb_sysdeps_posix.c",
199        "libavb_ab/avb_ab_flow.c",
200        "libavb_user/avb_ops_user.cpp",
201        "libavb_user/avb_user_verity.c",
202        "libavb_user/avb_user_verification.c",
203    ],
204}
205
206cc_binary {
207    name: "avbctl",
208    defaults: ["avb_defaults"],
209    static_libs: [
210        "libavb_user",
211        "libfs_mgr",
212    ],
213    shared_libs: [
214        "libbase",
215        "libcrypto",
216    ],
217    srcs: ["tools/avbctl/avbctl.cc"],
218}
219
220cc_library_host_static {
221    name: "libavb_ab_host",
222    defaults: ["avb_defaults"],
223    header_libs: [
224        "avb_headers",
225    ],
226    export_header_lib_headers: ["avb_headers"],
227    cflags: [
228        "-fno-stack-protector",
229        "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
230    ],
231    srcs: ["libavb_ab/avb_ab_flow.c"],
232}
233
234cc_defaults {
235    name: "avb_atx_sources",
236    srcs: ["libavb_atx/avb_atx_validate.c"],
237}
238
239cc_library_host_static {
240    name: "libavb_host_sysdeps",
241    defaults: ["avb_defaults"],
242    header_libs: [
243        "avb_headers",
244    ],
245    export_header_lib_headers: ["avb_headers"],
246    srcs: ["libavb/avb_sysdeps_posix.c"],
247}
248
249cc_defaults {
250    name: "avb_things_example_sources",
251    srcs: ["examples/things/avb_atx_slot_verify.c"],
252}
253
254cc_defaults {
255    name: "libavb_host_unittest_core",
256    defaults: [
257        "avb_defaults",
258        "avb_sources",
259        "avb_atx_sources",
260        "avb_things_example_sources",
261    ],
262    required: [
263        "simg2img",
264        "img2simg",
265        "avbtool",
266    ],
267    test_options: {
268        unit_test: true,
269    },
270    compile_multilib: "first",
271    data: [
272        "avbtool",
273        "test/avbtool_signing_helper_test.py",
274        "test/avbtool_signing_helper_with_files_test.py",
275        "test/data/*",
276    ],
277    test_config: "test/libavb_host_unittest.xml",
278    test_suites: ["general-tests"],
279    static_libs: [
280        "libavb_ab_host",
281        "libgmock_host",
282        "libgtest_host",
283    ],
284    shared_libs: [
285        "libbase",
286        "libchrome",
287        "libcrypto",
288    ],
289    cflags: [
290        "-Wno-missing-prototypes",
291        "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
292    ],
293    srcs: [
294        "test/avb_ab_flow_unittest.cc",
295        "test/avb_atx_validate_unittest.cc",
296        "test/avb_atx_slot_verify_unittest.cc",
297        "test/avb_crypto_ops_unittest.cc",
298        "test/avb_slot_verify_unittest.cc",
299        "test/avb_unittest_util.cc",
300        "test/avb_util_unittest.cc",
301        "test/avb_vbmeta_image_unittest.cc",
302        "test/avbtool_unittest.cc",
303        "test/fake_avb_ops.cc",
304        "test/avb_sysdeps_posix_testing.cc",
305    ],
306}
307
308cc_test_host {
309    name: "libavb_host_unittest",
310    defaults: [
311        "avb_crypto_ops_impl_boringssl",
312        "libavb_host_unittest_core",
313    ],
314    data: [
315        ":img2simg",
316        ":simg2img",
317        ":fec",
318    ],
319}
320
321cc_test_host {
322    name: "libavb_host_unittest_sha",
323    defaults: [
324        "avb_crypto_ops_impl_sha",
325        "libavb_host_unittest_core",
326    ],
327    data: [
328        ":img2simg",
329        ":simg2img",
330        ":fec",
331    ],
332}
333
334cc_library_host_static {
335    name: "libavb_host_user_code_test",
336    defaults: ["avb_defaults"],
337    cflags: [
338        "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
339    ],
340    srcs: ["test/user_code_test.cc"],
341}
342
343cc_library {
344    name: "bootctrl.avb",
345    defaults: ["avb_defaults"],
346    relative_install_path: "hw",
347    static_libs: [
348        "libavb_user",
349        "libfs_mgr",
350    ],
351    shared_libs: [
352        "libbase",
353        "libcrypto",
354        "libcutils",
355    ],
356    cflags: [
357        "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
358    ],
359    srcs: ["boot_control/boot_control_avb.c"],
360}
361
362cc_library_headers {
363    name: "avb_headers",
364    host_supported: true,
365    ramdisk_available: true,
366    vendor_ramdisk_available: true,
367    recovery_available: true,
368    export_include_dirs: ["."],
369    target: {
370        windows: {
371            enabled: true,
372        },
373    },
374}
375