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", |
David Zeuthen | 047ecf7 | 2017-06-28 14:10:55 -0400 | [diff] [blame] | 27 | "-Wmissing-prototypes", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 28 | "-Wno-psabi", |
| 29 | "-Wno-unused-parameter", |
Yi Kong | ed46d64 | 2018-01-03 11:52:56 -0800 | [diff] [blame] | 30 | "-Wno-format", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 31 | "-ffunction-sections", |
| 32 | "-fstack-protector-strong", |
| 33 | "-g", |
| 34 | "-DAVB_ENABLE_DEBUG", |
| 35 | "-DAVB_COMPILATION", |
| 36 | ], |
| 37 | cppflags: [ |
| 38 | "-Wnon-virtual-dtor", |
| 39 | "-fno-strict-aliasing", |
| 40 | ], |
| 41 | ldflags: [ |
| 42 | "-Wl,--gc-sections", |
| 43 | "-rdynamic", |
| 44 | ], |
| 45 | target: { |
| 46 | darwin: { |
| 47 | enabled: false, |
| 48 | }, |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | cc_defaults { |
| 53 | name: "avb_sources", |
| 54 | srcs: [ |
| 55 | "libavb/avb_chain_partition_descriptor.c", |
Lonnie Liu | 97740e5 | 2017-11-09 11:16:15 -0800 | [diff] [blame] | 56 | "libavb/avb_cmdline.c", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 57 | "libavb/avb_crc32.c", |
| 58 | "libavb/avb_crypto.c", |
| 59 | "libavb/avb_descriptor.c", |
| 60 | "libavb/avb_footer.c", |
| 61 | "libavb/avb_hash_descriptor.c", |
| 62 | "libavb/avb_hashtree_descriptor.c", |
| 63 | "libavb/avb_kernel_cmdline_descriptor.c", |
| 64 | "libavb/avb_property_descriptor.c", |
| 65 | "libavb/avb_rsa.c", |
| 66 | "libavb/avb_sha256.c", |
| 67 | "libavb/avb_sha512.c", |
| 68 | "libavb/avb_slot_verify.c", |
| 69 | "libavb/avb_util.c", |
| 70 | "libavb/avb_vbmeta_image.c", |
| 71 | "libavb/avb_version.c", |
| 72 | ], |
| 73 | } |
| 74 | |
| 75 | cc_prebuilt_binary { |
| 76 | name: "avbtool", |
| 77 | srcs: ["avbtool"], |
| 78 | required: ["fec"], |
| 79 | device_supported: false, |
| 80 | host_supported: true, |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | // Build libavb - this is a static library that depends |
| 84 | // on only libc and doesn't drag in any other dependencies. |
| 85 | cc_library_static { |
| 86 | name: "libavb", |
| 87 | defaults: [ |
| 88 | "avb_defaults", |
| 89 | "avb_sources", |
| 90 | ], |
| 91 | host_supported: true, |
| 92 | export_include_dirs: ["."], |
| 93 | target: { |
| 94 | android: { |
| 95 | srcs: ["libavb/avb_sysdeps_posix.c"], |
| 96 | }, |
Dan Willemsen | 34ec123 | 2017-10-02 10:41:07 -0700 | [diff] [blame] | 97 | linux_glibc: { |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 98 | cflags: ["-fno-stack-protector"], |
| 99 | }, |
| 100 | }, |
| 101 | } |
| 102 | |
| 103 | // Build libavb_user for the target - in addition to libavb, it |
| 104 | // includes libavb_ab, libavb_user and also depends on libbase and |
| 105 | // libfs_mgr. |
| 106 | cc_library_static { |
| 107 | name: "libavb_user", |
| 108 | defaults: [ |
| 109 | "avb_defaults", |
| 110 | "avb_sources", |
| 111 | ], |
| 112 | export_include_dirs: ["."], |
| 113 | shared_libs: ["libbase"], |
| 114 | static_libs: ["libfs_mgr"], |
David Zeuthen | 37f5946 | 2017-09-20 15:02:32 -0400 | [diff] [blame] | 115 | cflags: [ |
| 116 | "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED", |
| 117 | ], |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 118 | srcs: [ |
| 119 | "libavb/avb_sysdeps_posix.c", |
| 120 | "libavb_ab/avb_ab_flow.c", |
Bowgo Tsai | 84c610e | 2017-09-28 15:13:05 +0800 | [diff] [blame] | 121 | "libavb_user/avb_ops_user.cpp", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 122 | "libavb_user/avb_user_verity.c", |
David Zeuthen | 0922bf8 | 2017-06-19 17:50:38 -0400 | [diff] [blame] | 123 | "libavb_user/avb_user_verification.c", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 124 | ], |
| 125 | } |
| 126 | |
| 127 | cc_binary { |
| 128 | name: "avbctl", |
| 129 | defaults: ["avb_defaults"], |
| 130 | static_libs: [ |
| 131 | "libavb_user", |
| 132 | "libfs_mgr", |
| 133 | ], |
| 134 | shared_libs: ["libbase"], |
| 135 | srcs: ["tools/avbctl/avbctl.cc"], |
| 136 | } |
| 137 | |
| 138 | cc_library_host_static { |
| 139 | name: "libavb_ab_host", |
| 140 | defaults: ["avb_defaults"], |
| 141 | export_include_dirs: ["."], |
| 142 | cflags: [ |
| 143 | "-fno-stack-protector", |
David Zeuthen | 37f5946 | 2017-09-20 15:02:32 -0400 | [diff] [blame] | 144 | "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 145 | ], |
| 146 | srcs: ["libavb_ab/avb_ab_flow.c"], |
| 147 | } |
| 148 | |
| 149 | cc_library_host_static { |
| 150 | name: "libavb_atx_host", |
| 151 | defaults: ["avb_defaults"], |
| 152 | export_include_dirs: ["."], |
| 153 | cflags: [ |
| 154 | "-fno-stack-protector", |
| 155 | ], |
| 156 | srcs: ["libavb_atx/avb_atx_validate.c"], |
| 157 | } |
| 158 | |
| 159 | cc_library_host_static { |
| 160 | name: "libavb_host_sysdeps", |
| 161 | defaults: ["avb_defaults"], |
| 162 | export_include_dirs: ["."], |
| 163 | srcs: ["libavb/avb_sysdeps_posix.c"], |
| 164 | } |
| 165 | |
Darren Krahn | 8160f36 | 2017-10-05 22:11:02 -0700 | [diff] [blame] | 166 | cc_library_host_static { |
| 167 | name: "libavb_things_example", |
| 168 | defaults: ["avb_defaults"], |
| 169 | export_include_dirs: ["."], |
| 170 | srcs: ["examples/things/avb_atx_slot_verify.c"], |
| 171 | } |
| 172 | |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 173 | cc_test_host { |
| 174 | name: "libavb_host_unittest", |
| 175 | defaults: ["avb_defaults"], |
| 176 | required: [ |
| 177 | "simg2img", |
| 178 | "img2simg", |
| 179 | "avbtool", |
| 180 | ], |
| 181 | static_libs: [ |
| 182 | "libavb", |
| 183 | "libavb_ab_host", |
| 184 | "libavb_atx_host", |
Darren Krahn | 8160f36 | 2017-10-05 22:11:02 -0700 | [diff] [blame] | 185 | "libavb_things_example", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 186 | "libgmock_host", |
| 187 | "libgtest_host", |
| 188 | ], |
| 189 | shared_libs: [ |
| 190 | "libchrome", |
| 191 | "libcrypto", |
| 192 | ], |
David Zeuthen | 047ecf7 | 2017-06-28 14:10:55 -0400 | [diff] [blame] | 193 | cflags: [ |
| 194 | "-Wno-missing-prototypes", |
David Zeuthen | 37f5946 | 2017-09-20 15:02:32 -0400 | [diff] [blame] | 195 | "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED", |
David Zeuthen | 047ecf7 | 2017-06-28 14:10:55 -0400 | [diff] [blame] | 196 | ], |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 197 | srcs: [ |
| 198 | "test/avb_ab_flow_unittest.cc", |
| 199 | "test/avb_atx_validate_unittest.cc", |
Darren Krahn | 8160f36 | 2017-10-05 22:11:02 -0700 | [diff] [blame] | 200 | "test/avb_atx_slot_verify_unittest.cc", |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 201 | "test/avb_slot_verify_unittest.cc", |
| 202 | "test/avb_unittest_util.cc", |
| 203 | "test/avb_util_unittest.cc", |
| 204 | "test/avb_vbmeta_image_unittest.cc", |
| 205 | "test/avbtool_unittest.cc", |
| 206 | "test/fake_avb_ops.cc", |
| 207 | "test/avb_sysdeps_posix_testing.cc", |
| 208 | ], |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | cc_library_host_static { |
| 212 | name: "libavb_host_user_code_test", |
| 213 | defaults: ["avb_defaults"], |
David Zeuthen | 37f5946 | 2017-09-20 15:02:32 -0400 | [diff] [blame] | 214 | cflags: [ |
| 215 | "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED", |
| 216 | ], |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 217 | srcs: ["test/user_code_test.cc"], |
| 218 | } |
| 219 | |
| 220 | cc_library { |
| 221 | name: "bootctrl.avb", |
| 222 | defaults: ["avb_defaults"], |
| 223 | relative_install_path: "hw", |
| 224 | static_libs: [ |
| 225 | "libavb_user", |
| 226 | "libfs_mgr", |
| 227 | ], |
| 228 | shared_libs: [ |
| 229 | "libbase", |
| 230 | "libcutils", |
| 231 | ], |
David Zeuthen | 37f5946 | 2017-09-20 15:02:32 -0400 | [diff] [blame] | 232 | cflags: [ |
| 233 | "-DAVB_AB_I_UNDERSTAND_LIBAVB_AB_IS_DEPRECATED", |
| 234 | ], |
Tom Cherry | 8d225d8 | 2017-05-12 17:00:31 -0700 | [diff] [blame] | 235 | srcs: ["boot_control/boot_control_avb.c"], |
| 236 | } |