Allow to statically link heapprofd into client.

This allows us to use heapprofd on standalone Linux and to sideload onto
older versions of Android.

Test: Profile heapprofd_static_client_example on Linux.

Bug: 160399441
Bug: 160400319

Change-Id: I63159a8ade3d7c1f7bfecb9536a2c3abaa78cbf6
diff --git a/tools/heap_profile b/tools/heap_profile
index d25f36b..349af0c 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -265,19 +265,6 @@
       default=None)
 
   args = parser.parse_args()
-
-  # TODO(fmayer): Maybe feature detect whether we can remove traces instead of
-  # this.
-  uuid_trace = release_or_newer('R')
-  if uuid_trace:
-    profile_device_path = '/data/misc/perfetto-traces/profile-' + UUID
-  else:
-    user = subprocess.check_output(
-      ['adb', 'shell', 'whoami']).decode('utf-8').strip()
-    profile_device_path = '/data/misc/perfetto-traces/profile-' + user
-  perfetto_cmd = ('CFG=\'{cfg}\'; echo ${{CFG}} | '
-                  'perfetto --txt -c - -o ' + profile_device_path + ' -d')
-
   fail = False
   if args.block_client and args.no_block_client:
     print(
@@ -366,6 +353,19 @@
     print(cfg)
     return 0
 
+  # TODO(fmayer): Maybe feature detect whether we can remove traces instead of
+  # this.
+  uuid_trace = release_or_newer('R')
+  if uuid_trace:
+    profile_device_path = '/data/misc/perfetto-traces/profile-' + UUID
+  else:
+    user = subprocess.check_output(
+      ['adb', 'shell', 'whoami']).decode('utf-8').strip()
+    profile_device_path = '/data/misc/perfetto-traces/profile-' + user
+
+  perfetto_cmd = ('CFG=\'{cfg}\'; echo ${{CFG}} | '
+                  'perfetto --txt -c - -o ' + profile_device_path + ' -d')
+
   if args.disable_selinux:
     enforcing = subprocess.check_output(['adb', 'shell', 'getenforce'])
     atexit.register(