libbootloader_message: host_supported.

Also, strlcat is not available on host, so use
std::string::operator+= instead.

Test: cuttlefish
Bug: 79094284

Change-Id: I1e69daeb522ca73f43e0c4855cf099a021ed4d47
diff --git a/bootloader_message/Android.bp b/bootloader_message/Android.bp
index 5cd2132..4ea7c86 100644
--- a/bootloader_message/Android.bp
+++ b/bootloader_message/Android.bp
@@ -17,6 +17,7 @@
 cc_library {
     name: "libbootloader_message",
     recovery_available: true,
+    host_supported: true,
     srcs: ["bootloader_message.cpp"],
     cflags: [
         "-Wall",
@@ -24,7 +25,22 @@
     ],
     shared_libs: [
         "libbase",
-        "libfs_mgr",
     ],
     export_include_dirs: ["include"],
+
+    target: {
+        android: {
+            shared_libs: [
+                "libfs_mgr",
+            ],
+        },
+        host: {
+            shared_libs: [
+                "libcutils", // for strlcpy
+            ],
+            static_libs: [
+                "libfstab",
+            ],
+        }
+    }
 }
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index 0ebc04a..331a42b 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -29,6 +29,10 @@
 #include <android-base/unique_fd.h>
 #include <fstab/fstab.h>
 
+#ifndef __ANDROID__
+#include <cutils/memory.h>  // for strlcpy
+#endif
+
 using android::fs_mgr::Fstab;
 using android::fs_mgr::ReadDefaultFstab;
 
@@ -194,13 +198,15 @@
   memset(boot->recovery, 0, sizeof(boot->recovery));
 
   strlcpy(boot->command, "boot-recovery", sizeof(boot->command));
-  strlcpy(boot->recovery, "recovery\n", sizeof(boot->recovery));
+
+  std::string recovery = "recovery\n";
   for (const auto& s : options) {
-    strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery));
+    recovery += s;
     if (s.back() != '\n') {
-      strlcat(boot->recovery, "\n", sizeof(boot->recovery));
+      recovery += '\n';
     }
   }
+  strlcpy(boot->recovery, recovery.c_str(), sizeof(boot->recovery));
   return true;
 }