androidbp: Optimize cc_library builds, share static lib
If the cflags are identical, and there aren't extra sources in the
static version of a cc_library, then we can re-use the static library in
the build of the shared library.
Change-Id: I54c59aa3edcc47bc777132461b8e6a84cef0587e
diff --git a/androidbp/cmd/androidbp_test.go b/androidbp/cmd/androidbp_test.go
index cf5be7a..081a1ca 100644
--- a/androidbp/cmd/androidbp_test.go
+++ b/androidbp/cmd/androidbp_test.go
@@ -76,13 +76,17 @@
},
// Static and Shared
{
- blueprint: `cc_library { name: "test", }`,
+ blueprint: `cc_library { name: "test", srcs: ["a"], }`,
androidmk: `include $(CLEAR_VARS)
LOCAL_MODULE := test
+ LOCAL_WHOLE_STATIC_LIBRARIES := \
+ test
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := test
+ LOCAL_SRC_FILES := \
+ a
include $(BUILD_STATIC_LIBRARY)`,
},
// Static and Shared / Target and Host
@@ -90,6 +94,8 @@
blueprint: `cc_library { name: "test", host_supported: true, }`,
androidmk: `include $(CLEAR_VARS)
LOCAL_MODULE := test
+ LOCAL_WHOLE_STATIC_LIBRARIES := \
+ test
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
@@ -98,6 +104,8 @@
include $(CLEAR_VARS)
LOCAL_MODULE := test
+ LOCAL_WHOLE_STATIC_LIBRARIES := \
+ test
include $(BUILD_HOST_SHARED_LIBRARY)
include $(CLEAR_VARS)
@@ -131,6 +139,27 @@
l
include $(BUILD_STATIC_LIBRARY)`,
},
+ // Static and Shared properties, use whole static lib, but add extra shared srcs
+ {
+ blueprint: `cc_library {
+ name: "test",
+ srcs: ["a"],
+ shared: { srcs: ["b"], },
+ }`,
+ androidmk: `include $(CLEAR_VARS)
+ LOCAL_MODULE := test
+ LOCAL_WHOLE_STATIC_LIBRARIES := \
+ test
+ LOCAL_SRC_FILES := \
+ b
+ include $(BUILD_SHARED_LIBRARY)
+
+ include $(CLEAR_VARS)
+ LOCAL_MODULE := test
+ LOCAL_SRC_FILES := \
+ a
+ include $(BUILD_STATIC_LIBRARY)`,
+ },
// Manual translation
{
blueprint: `/* Android.mk:start