Bundle profman in the host module exports.

It's used for boot image profiling in platform.

This means its host variants need to be static (except for system
deps).

Test: art/build/build-art-module.sh
      packages/modules/ArtPrebuilt/update-art-module-prebuilts.py \
        --local-dist out/dist/ --skip-cls --skip-apex
      m droid SOONG_CONFIG_art_module_source_build=false
  Also check that
  prebuilts/module_sdk/art/current/host-exports/x86_64/bin/profman only
  has DT_NEEDED on standard system libs.
Bug: 172480615
Change-Id: I0a2c183f049be83d78be44f1fccbfbf212a7c455
diff --git a/profman/Android.bp b/profman/Android.bp
index 1267d95..366bd85 100644
--- a/profman/Android.bp
+++ b/profman/Android.bp
@@ -37,25 +37,66 @@
         android: {
             // Use the 32-bit version of profman on devices.
             compile_multilib: "prefer32",
+            shared_libs: [
+                "libbase",
+            ],
+        },
+        host: {
+            whole_static_libs: [
+                "libbase",
+            ],
         },
         darwin: {
             enabled: true,
         },
     },
+}
 
-    shared_libs: [
-        "libbase",
+// Collect all the static defaults and build a host-only static library, which
+// is then used for the (mostly) static host profman binary.
+art_cc_library_static {
+    name: "libprofman_static",
+    device_supported: false,
+    host_supported: true,
+    defaults: [
+        "art_defaults",
+        "libartbase_static_defaults",
+        "libdexfile_static_defaults",
+        "libprofile_static_defaults",
+    ],
+}
+
+art_cc_library_static {
+    name: "libprofmand_static",
+    device_supported: false,
+    host_supported: true,
+    defaults: [
+        "art_debug_defaults",
+        "libartbased_static_defaults",
+        "libdexfiled_static_defaults",
+        "libprofiled_static_defaults",
     ],
 }
 
 art_cc_binary {
     name: "profman",
     defaults: ["profman-defaults"],
-    shared_libs: [
-        "libprofile",
-        "libdexfile",
-        "libartbase",
-    ],
+    target: {
+        android: {
+            shared_libs: [
+                "libartbase",
+                "libdexfile",
+                "libprofile",
+            ],
+        },
+        host: {
+            // Make the host binary static, except for system libraries. This
+            // avoids having to bundle host dynamic libs in prebuilts.
+            static_libs: ["libprofman_static"],
+            stl: "c++_static",
+
+        },
+    },
     apex_available: [
         "com.android.art",
         "com.android.art.debug",
@@ -68,11 +109,22 @@
         "art_debug_defaults",
         "profman-defaults",
     ],
-    shared_libs: [
-        "libprofiled",
-        "libdexfiled",
-        "libartbased",
-    ],
+    target: {
+        android: {
+            shared_libs: [
+                "libartbased",
+                "libdexfiled",
+                "libprofiled",
+            ],
+        },
+        host: {
+            // Make the host binary static, except for system libraries. This
+            // avoids having to bundle host dynamic libs in prebuilts.
+            static_libs: ["libprofmand_static"],
+            stl: "c++_static",
+
+        },
+    },
     apex_available: [
         "com.android.art.debug",
     ],