Fix test build rules for different SHA implementations

The tests were linking against libraries that had different expectations
for the SHA implementation leading to memory issues. Resolve the
conflicts by building the dependencies from source so the correct SHA
implementation is used by all the code under test.

The problems was, in part, hidden due to an atest bug b/211900473 that
meant the custom SHA implementation variant of the test wasn't actually
being run. It needs to be run manually to confirm the fix until that is
resolved.

Test: ./libavb_host_unittest_sha
Bug: 211287350
Change-Id: I32b944fde9c133d1b9697a509ff66a26e084d6c4
diff --git a/Android.bp b/Android.bp
index 6685ab2..0aae847 100644
--- a/Android.bp
+++ b/Android.bp
@@ -147,7 +147,8 @@
     compile_multilib: "first",
 }
 
-// on only libc and doesn't drag in any other dependencies.
+// Build libavb - this is a static library that depends
+// on only libc and libcrypto, but no other dependencies.
 cc_library_static {
     name: "libavb",
     defaults: [
@@ -230,19 +231,8 @@
     srcs: ["libavb_ab/avb_ab_flow.c"],
 }
 
-cc_library_host_static {
-    name: "libavb_atx_host",
-    defaults: [
-        "avb_defaults",
-        "avb_crypto_ops_impl_boringssl",
-    ],
-    header_libs: [
-        "avb_headers",
-    ],
-    export_header_lib_headers: ["avb_headers"],
-    cflags: [
-        "-fno-stack-protector",
-    ],
+cc_defaults {
+    name: "avb_atx_sources",
     srcs: ["libavb_atx/avb_atx_validate.c"],
 }
 
@@ -256,22 +246,19 @@
     srcs: ["libavb/avb_sysdeps_posix.c"],
 }
 
-cc_library_host_static {
-    name: "libavb_things_example",
-    defaults: [
-        "avb_defaults",
-        "avb_crypto_ops_impl_boringssl",
-    ],
-    header_libs: [
-        "avb_headers",
-    ],
-    export_header_lib_headers: ["avb_headers"],
+cc_defaults {
+    name: "avb_things_example_sources",
     srcs: ["examples/things/avb_atx_slot_verify.c"],
 }
 
 cc_defaults {
     name: "libavb_host_unittest_core",
-    defaults: ["avb_defaults"],
+    defaults: [
+        "avb_defaults",
+        "avb_sources",
+        "avb_atx_sources",
+        "avb_things_example_sources",
+    ],
     required: [
         "simg2img",
         "img2simg",
@@ -290,10 +277,7 @@
     test_config: "test/libavb_host_unittest.xml",
     test_suites: ["general-tests"],
     static_libs: [
-        "libavb",
         "libavb_ab_host",
-        "libavb_atx_host",
-        "libavb_things_example",
         "libgmock_host",
         "libgtest_host",
     ],