Move proto, c++, and test libs to static
Link libgtest_prod, libprotobuf-cpp-lite, and libc++ statically.
This reduces the size of the statsd apex from 2.8M to 1.6M.
Initial:
blueline:/apex/com.android.os.statsd # du -h
16K ./lost+found
764K ./bin
1.3M ./lib64
8.0K ./etc
600K ./lib
120K ./javalib
2.8M .
After linking proto lite and libgtest_prod statically (saves ~500kb):
blueline:/apex/com.android.os.statsd # du -h
16K ./lost+found
800K ./bin
876K ./lib64
8.0K ./etc
600K ./lib
120K ./javalib
2.3M .
After also linking libc++ statically (saves ~700kb):
blueline:/apex/com.android.os.statsd # du -h
16K ./lost+found
0.9M ./bin
296K ./lib64
8.0K ./etc
204K ./lib
120K ./javalib
1.6M .
After this change, the only libraries in both /lib and /lib64 are:
libstats_jni.so
libstatspull.so
libstatssocket.so
These are the 3 libraries we actually want to ship.
Test: m
Test: bit statsd_test:*
Test: atest GtsStatsdHostTestCases
Test: manually inspecting the size of the apex, statsd binary, and
libraries
Bug: 153349706
Bug: 153349659
Bug: 153350187
Change-Id: I00796fc1cf33e394422c6dc617a8430a5f5c5bbb
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 20f9e76..bfd1272 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -114,17 +114,18 @@
static_libs: [
"libbase",
"libcutils",
+ "libgtest_prod",
"libprotoutil",
"libstatsmetadata",
"libstatslog_statsd",
"libsysutils",
"libutils",
+ "statsd-aidl-ndk_platform",
],
shared_libs: [
"libbinder_ndk",
"libincident",
"liblog",
- "statsd-aidl-ndk_platform",
],
}
@@ -269,10 +270,11 @@
proto: {
type: "lite",
+ static: true,
},
+ stl: "libc++_static",
shared_libs: [
- "libgtest_prod",
"libstatssocket",
],