Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame^] | 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 | "-Wno-psabi", |
| 28 | "-Wno-unused-parameter", |
| 29 | "-ffunction-sections", |
| 30 | "-fstack-protector-strong", |
| 31 | "-g", |
| 32 | "-DAVB_ENABLE_DEBUG", |
| 33 | "-DAVB_COMPILATION", |
| 34 | ], |
| 35 | cppflags: [ |
| 36 | "-Wnon-virtual-dtor", |
| 37 | "-fno-strict-aliasing", |
| 38 | ], |
| 39 | ldflags: [ |
| 40 | "-Wl,--gc-sections", |
| 41 | "-rdynamic", |
| 42 | ], |
| 43 | target: { |
| 44 | darwin: { |
| 45 | enabled: false, |
| 46 | }, |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | cc_defaults { |
| 51 | name: "avb_sources", |
| 52 | srcs: [ |
| 53 | "libavb/avb_chain_partition_descriptor.c", |
| 54 | "libavb/avb_crc32.c", |
| 55 | "libavb/avb_crypto.c", |
| 56 | "libavb/avb_descriptor.c", |
| 57 | "libavb/avb_footer.c", |
| 58 | "libavb/avb_hash_descriptor.c", |
| 59 | "libavb/avb_hashtree_descriptor.c", |
| 60 | "libavb/avb_kernel_cmdline_descriptor.c", |
| 61 | "libavb/avb_property_descriptor.c", |
| 62 | "libavb/avb_rsa.c", |
| 63 | "libavb/avb_sha256.c", |
| 64 | "libavb/avb_sha512.c", |
| 65 | "libavb/avb_slot_verify.c", |
| 66 | "libavb/avb_util.c", |
| 67 | "libavb/avb_vbmeta_image.c", |
| 68 | "libavb/avb_version.c", |
| 69 | ], |
| 70 | } |
| 71 | |
| 72 | cc_prebuilt_binary { |
| 73 | name: "avbtool", |
| 74 | srcs: ["avbtool"], |
| 75 | required: ["fec"], |
| 76 | device_supported: false, |
| 77 | host_supported: true, |
| 78 | target: { |
| 79 | darwin: { |
| 80 | enabled: false, |
| 81 | }, |
| 82 | }, |
| 83 | } |
| 84 | |
| 85 | // Build libavb - this is a static library that depends |
| 86 | // on only libc and doesn't drag in any other dependencies. |
| 87 | cc_library_static { |
| 88 | name: "libavb", |
| 89 | defaults: [ |
| 90 | "avb_defaults", |
| 91 | "avb_sources", |
| 92 | ], |
| 93 | host_supported: true, |
| 94 | export_include_dirs: ["."], |
| 95 | target: { |
| 96 | android: { |
| 97 | srcs: ["libavb/avb_sysdeps_posix.c"], |
| 98 | }, |
| 99 | linux: { |
| 100 | cflags: ["-fno-stack-protector"], |
| 101 | }, |
| 102 | }, |
| 103 | } |
| 104 | |
| 105 | // Build libavb_user for the target - in addition to libavb, it |
| 106 | // includes libavb_ab, libavb_user and also depends on libbase and |
| 107 | // libfs_mgr. |
| 108 | cc_library_static { |
| 109 | name: "libavb_user", |
| 110 | defaults: [ |
| 111 | "avb_defaults", |
| 112 | "avb_sources", |
| 113 | ], |
| 114 | export_include_dirs: ["."], |
| 115 | shared_libs: ["libbase"], |
| 116 | static_libs: ["libfs_mgr"], |
| 117 | srcs: [ |
| 118 | "libavb/avb_sysdeps_posix.c", |
| 119 | "libavb_ab/avb_ab_flow.c", |
| 120 | "libavb_user/avb_ops_user.c", |
| 121 | "libavb_user/avb_user_verity.c", |
| 122 | ], |
| 123 | } |
| 124 | |
| 125 | cc_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 | |
| 136 | cc_library_host_static { |
| 137 | name: "libavb_ab_host", |
| 138 | defaults: ["avb_defaults"], |
| 139 | export_include_dirs: ["."], |
| 140 | cflags: [ |
| 141 | "-fno-stack-protector", |
| 142 | ], |
| 143 | srcs: ["libavb_ab/avb_ab_flow.c"], |
| 144 | } |
| 145 | |
| 146 | cc_library_host_static { |
| 147 | name: "libavb_atx_host", |
| 148 | defaults: ["avb_defaults"], |
| 149 | export_include_dirs: ["."], |
| 150 | cflags: [ |
| 151 | "-fno-stack-protector", |
| 152 | ], |
| 153 | srcs: ["libavb_atx/avb_atx_validate.c"], |
| 154 | } |
| 155 | |
| 156 | cc_library_host_static { |
| 157 | name: "libavb_host_sysdeps", |
| 158 | defaults: ["avb_defaults"], |
| 159 | export_include_dirs: ["."], |
| 160 | srcs: ["libavb/avb_sysdeps_posix.c"], |
| 161 | } |
| 162 | |
| 163 | cc_test_host { |
| 164 | name: "libavb_host_unittest", |
| 165 | defaults: ["avb_defaults"], |
| 166 | required: [ |
| 167 | "simg2img", |
| 168 | "img2simg", |
| 169 | "avbtool", |
| 170 | ], |
| 171 | static_libs: [ |
| 172 | "libavb", |
| 173 | "libavb_ab_host", |
| 174 | "libavb_atx_host", |
| 175 | "libgmock_host", |
| 176 | "libgtest_host", |
| 177 | ], |
| 178 | shared_libs: [ |
| 179 | "libchrome", |
| 180 | "libcrypto", |
| 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 | } |