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 cc_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", 27 "-Wmissing-prototypes", 28 "-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 51 cc_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 73 cc_prebuilt_binary { 74 name: "avbtool", 75 srcs: ["avbtool"], 76 required: ["fec"], 77 device_supported: false, 78 host_supported: true, 79 } 80 81 // Build libavb - this is a static library that depends 82 // on only libc and doesn't drag in any other dependencies. 83 cc_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. 104 cc_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"], 113 srcs: [ 114 "libavb/avb_sysdeps_posix.c", 115 "libavb_ab/avb_ab_flow.c", 116 "libavb_user/avb_ops_user.c", 117 "libavb_user/avb_user_verity.c", 118 "libavb_user/avb_user_verification.c", 119 ], 120 } 121 122 cc_binary { 123 name: "avbctl", 124 defaults: ["avb_defaults"], 125 static_libs: [ 126 "libavb_user", 127 "libfs_mgr", 128 ], 129 shared_libs: ["libbase"], 130 srcs: ["tools/avbctl/avbctl.cc"], 131 } 132 133 cc_library_host_static { 134 name: "libavb_ab_host", 135 defaults: ["avb_defaults"], 136 export_include_dirs: ["."], 137 cflags: [ 138 "-fno-stack-protector", 139 ], 140 srcs: ["libavb_ab/avb_ab_flow.c"], 141 } 142 143 cc_library_host_static { 144 name: "libavb_atx_host", 145 defaults: ["avb_defaults"], 146 export_include_dirs: ["."], 147 cflags: [ 148 "-fno-stack-protector", 149 ], 150 srcs: ["libavb_atx/avb_atx_validate.c"], 151 } 152 153 cc_library_host_static { 154 name: "libavb_host_sysdeps", 155 defaults: ["avb_defaults"], 156 export_include_dirs: ["."], 157 srcs: ["libavb/avb_sysdeps_posix.c"], 158 } 159 160 cc_test_host { 161 name: "libavb_host_unittest", 162 defaults: ["avb_defaults"], 163 required: [ 164 "simg2img", 165 "img2simg", 166 "avbtool", 167 ], 168 static_libs: [ 169 "libavb", 170 "libavb_ab_host", 171 "libavb_atx_host", 172 "libgmock_host", 173 "libgtest_host", 174 ], 175 shared_libs: [ 176 "libchrome", 177 "libcrypto", 178 ], 179 cflags: [ 180 "-Wno-missing-prototypes", 181 ], 182 srcs: [ 183 "test/avb_ab_flow_unittest.cc", 184 "test/avb_atx_validate_unittest.cc", 185 "test/avb_slot_verify_unittest.cc", 186 "test/avb_unittest_util.cc", 187 "test/avb_util_unittest.cc", 188 "test/avb_vbmeta_image_unittest.cc", 189 "test/avbtool_unittest.cc", 190 "test/fake_avb_ops.cc", 191 "test/avb_sysdeps_posix_testing.cc", 192 ], 193 host_ldlibs: ["-lrt"], 194 } 195 196 cc_library_host_static { 197 name: "libavb_host_user_code_test", 198 defaults: ["avb_defaults"], 199 srcs: ["test/user_code_test.cc"], 200 } 201 202 cc_library { 203 name: "bootctrl.avb", 204 defaults: ["avb_defaults"], 205 relative_install_path: "hw", 206 static_libs: [ 207 "libavb_user", 208 "libfs_mgr", 209 ], 210 shared_libs: [ 211 "libbase", 212 "libcutils", 213 ], 214 srcs: ["boot_control/boot_control_avb.c"], 215 } 216