Home | History | Annotate | Download | only in avb
      1 //
      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 
     17 subdirs = ["test", "tools"]
     18 
     19 cc_defaults {
     20     name: "avb_defaults",
     21     cflags: [
     22         "-D_FILE_OFFSET_BITS=64",
     23         "-D_POSIX_C_SOURCE=199309L",
     24         "-Wa,--noexecstack",
     25         "-Werror",
     26         "-Wall",
     27         "-Wextra",
     28         "-Wformat=2",
     29         "-Wmissing-prototypes",
     30         "-Wno-psabi",
     31         "-Wno-unused-parameter",
     32         "-Wno-format",
     33         "-ffunction-sections",
     34         "-fstack-protector-strong",
     35         "-g",
     36         "-DAVB_ENABLE_DEBUG",
     37         "-DAVB_COMPILATION",
     38     ],
     39     cppflags: [
     40         "-Wnon-virtual-dtor",
     41         "-fno-strict-aliasing",
     42     ],
     43     ldflags: [
     44         "-Wl,--gc-sections",
     45         "-rdynamic",
     46     ],
     47     target: {
     48         darwin: {
     49             enabled: false,
     50         },
     51     },
     52 }
     53 
     54 cc_defaults {
     55     name: "avb_sources",
     56     srcs: [
     57         "libavb/avb_chain_partition_descriptor.c",
     58         "libavb/avb_cmdline.c",
     59         "libavb/avb_crc32.c",
     60         "libavb/avb_crypto.c",
     61         "libavb/avb_descriptor.c",
     62         "libavb/avb_footer.c",
     63         "libavb/avb_hash_descriptor.c",
     64         "libavb/avb_hashtree_descriptor.c",
     65         "libavb/avb_kernel_cmdline_descriptor.c",
     66         "libavb/avb_property_descriptor.c",
     67         "libavb/avb_rsa.c",
     68         "libavb/avb_sha256.c",
     69         "libavb/avb_sha512.c",
     70         "libavb/avb_slot_verify.c",
     71         "libavb/avb_util.c",
     72         "libavb/avb_vbmeta_image.c",
     73         "libavb/avb_version.c",
     74     ],
     75 }
     76 
     77 python_binary_host {
     78     name: "avbtool",
     79     srcs: [":avbtool_py"],
     80     main: "avbtool.py",
     81     required: ["fec"],
     82     version: {
     83         py2: {
     84             enabled: true,
     85             embedded_launcher: true,
     86         },
     87         py3: {
     88             enabled: false,
     89         },
     90     },
     91 }
     92 
     93 genrule {
     94   name: "avbtool_py",
     95   srcs: ["avbtool",],
     96   out: ["avbtool.py"],
     97   cmd: "cp $(in) $(out)",
     98 }
     99 
    100 // Build libavb - this is a static library that depends
    101 // on only libc and doesn't drag in any other dependencies.
    102 cc_library_static {
    103     name: "libavb",
    104     defaults: [
    105         "avb_defaults",
    106         "avb_sources",
    107     ],
    108     host_supported: true,
    109     recovery_available: true,
    110     export_include_dirs: ["."],
    111     target: {
    112         linux: {
    113             srcs: ["libavb/avb_sysdeps_posix.c"],
    114         },
    115         linux_glibc: {
    116             cflags: ["-fno-stack-protector"],
    117         },
    118     },
    119 }
    120 
    121 // Build libavb_user for the target - in addition to libavb, it
    122 // includes libavb_ab, libavb_user and also depends on libbase and
    123 // libfs_mgr.
    124 cc_library_static {
    125     name: "libavb_user",
    126     defaults: [
    127         "avb_defaults",
    128         "avb_sources",
    129     ],
    130     recovery_available: true,
    131     export_include_dirs: ["."],
    132     shared_libs: ["libbase"],
    133     static_libs: ["libfs_mgr"],
    134     cflags: [
    135         "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
    136     ],
    137     srcs: [
    138         "libavb/avb_sysdeps_posix.c",
    139         "libavb_ab/avb_ab_flow.c",
    140         "libavb_user/avb_ops_user.cpp",
    141         "libavb_user/avb_user_verity.c",
    142         "libavb_user/avb_user_verification.c",
    143     ],
    144 }
    145 
    146 cc_binary {
    147     name: "avbctl",
    148     defaults: ["avb_defaults"],
    149     static_libs: [
    150         "libavb_user",
    151         "libfs_mgr",
    152     ],
    153     shared_libs: ["libbase"],
    154     srcs: ["tools/avbctl/avbctl.cc"],
    155 }
    156 
    157 cc_library_host_static {
    158     name: "libavb_ab_host",
    159     defaults: ["avb_defaults"],
    160     export_include_dirs: ["."],
    161     cflags: [
    162         "-fno-stack-protector",
    163         "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
    164     ],
    165     srcs: ["libavb_ab/avb_ab_flow.c"],
    166 }
    167 
    168 cc_library_host_static {
    169     name: "libavb_atx_host",
    170     defaults: ["avb_defaults"],
    171     export_include_dirs: ["."],
    172     cflags: [
    173         "-fno-stack-protector",
    174     ],
    175     srcs: ["libavb_atx/avb_atx_validate.c"],
    176 }
    177 
    178 cc_library_host_static {
    179     name: "libavb_host_sysdeps",
    180     defaults: ["avb_defaults"],
    181     export_include_dirs: ["."],
    182     srcs: ["libavb/avb_sysdeps_posix.c"],
    183 }
    184 
    185 cc_library_host_static {
    186     name: "libavb_things_example",
    187     defaults: ["avb_defaults"],
    188     export_include_dirs: ["."],
    189     srcs: ["examples/things/avb_atx_slot_verify.c"],
    190 }
    191 
    192 cc_test_host {
    193     name: "libavb_host_unittest",
    194     defaults: ["avb_defaults"],
    195     required: [
    196         "simg2img",
    197         "img2simg",
    198         "avbtool",
    199     ],
    200     data: [
    201         "avbtool",
    202         "test/avbtool_signing_helper_*.py",
    203         "test/data/*",
    204     ],
    205     test_config: "test/libavb_host_unittest.xml",
    206     test_suites: ["general-tests"],
    207     static_libs: [
    208         "libavb",
    209         "libavb_ab_host",
    210         "libavb_atx_host",
    211         "libavb_things_example",
    212         "libgmock_host",
    213         "libgtest_host",
    214     ],
    215     shared_libs: [
    216         "libbase",
    217         "libchrome",
    218         "libcrypto",
    219     ],
    220     cflags: [
    221             "-Wno-missing-prototypes",
    222             "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
    223     ],
    224     srcs: [
    225         "test/avb_ab_flow_unittest.cc",
    226         "test/avb_atx_validate_unittest.cc",
    227         "test/avb_atx_slot_verify_unittest.cc",
    228         "test/avb_slot_verify_unittest.cc",
    229         "test/avb_unittest_util.cc",
    230         "test/avb_util_unittest.cc",
    231         "test/avb_vbmeta_image_unittest.cc",
    232         "test/avbtool_unittest.cc",
    233         "test/fake_avb_ops.cc",
    234         "test/avb_sysdeps_posix_testing.cc",
    235     ],
    236 }
    237 
    238 cc_library_host_static {
    239     name: "libavb_host_user_code_test",
    240     defaults: ["avb_defaults"],
    241     cflags: [
    242         "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
    243     ],
    244     srcs: ["test/user_code_test.cc"],
    245 }
    246 
    247 cc_library {
    248     name: "bootctrl.avb",
    249     defaults: ["avb_defaults"],
    250     relative_install_path: "hw",
    251     static_libs: [
    252         "libavb_user",
    253         "libfs_mgr",
    254     ],
    255     shared_libs: [
    256         "libbase",
    257         "libcutils",
    258     ],
    259     cflags: [
    260         "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED",
    261     ],
    262     srcs: ["boot_control/boot_control_avb.c"],
    263 }
    264