From b8ddd55b55e1016ad1b6f8f2171aa4ee3e91aec2 Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Mon, 15 Sep 2014 17:51:11 -0700 Subject: [PATCH] Pull in latest protolib when using LOCAL_PROTOC_OPTIMIZE_TYPE. If a module is explicitly depending on a versioned protolib, we strip the dependency and log a warning so the unneeded dependency can be removed. Change-Id: I949d32fb5126f1c05e2a6ed48f6636a4a9b15a48 --- core/binary.mk | 12 ++++++++++-- core/host_java_library_common.mk | 18 +++++++++++++++--- core/java.mk | 18 +++++++++++++++--- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index efb0db0ff..7a5cd2e5f 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -538,9 +538,17 @@ $(proto_generated_objects): $(proto_generated_obj_dir)/%.o: $(proto_generated_cc my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir) my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) -my_static_libraries += libprotobuf-cpp-2.3.0-full + ifneq ($(filter libprotobuf-cpp-2.3.0-full,$(my_static_libraries)),) + $(warning Stripping unneeded dependency on libprotobuf-cpp-2.3.0-full in $(LOCAL_MODULE)) + my_static_libraries := $(filter-out libprotobuf-cpp-2.3.0-full,$(my_static_libraries)) + endif + my_static_libraries += libprotobuf-cpp-full else -my_static_libraries += libprotobuf-cpp-2.3.0-lite + ifneq ($(filter libprotobuf-cpp-2.3.0-lite,$(my_static_libraries)),) + $(warning Stripping unneeded dependency on libprotobuf-cpp-2.3.0-lite in $(LOCAL_MODULE)) + my_static_libraries := $(filter-out libprotobuf-cpp-2.3.0-lite,$(my_static_libraries)) + endif + my_static_libraries += libprotobuf-cpp-lite endif endif # $(proto_sources) non-empty diff --git a/core/host_java_library_common.mk b/core/host_java_library_common.mk index 973afa03f..a675a84dc 100644 --- a/core/host_java_library_common.mk +++ b/core/host_java_library_common.mk @@ -29,12 +29,24 @@ all_res_assets := proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) ifneq ($(proto_sources),) ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) - LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-micro + ifneq ($(filter host-libprotobuf-java-2.3.0-micro,$(LOCAL_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on host-libprotobuf-java-2.3.0-micro in $(LOCAL_MODULE)) + LOCAL_JAVA_LIBRARIES := $(filter-out host-libprotobuf-java-2.3.0-micro,$(LOCAL_JAVA_LIBRARIES)) + endif + LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-micro else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) - LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-nano + ifneq ($(filter host-libprotobuf-java-2.3.0-nano,$(LOCAL_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on host-libprotobuf-java-2.3.0-nano in $(LOCAL_MODULE)) + LOCAL_JAVA_LIBRARIES := $(filter-out host-libprotobuf-java-2.3.0-nano,$(LOCAL_JAVA_LIBRARIES)) + endif + LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-nano else - LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-lite + ifneq ($(filter host-libprotobuf-java-2.3.0-lite,$(LOCAL_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on host-libprotobuf-java-2.3.0-lite in $(LOCAL_MODULE)) + LOCAL_JAVA_LIBRARIES := $(filter-out host-libprotobuf-java-2.3.0-lite,$(LOCAL_JAVA_LIBRARIES)) + endif + LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-lite endif endif endif diff --git a/core/java.mk b/core/java.mk index 049bc5110..8fdf61a7b 100644 --- a/core/java.mk +++ b/core/java.mk @@ -40,12 +40,24 @@ endif proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) ifneq ($(proto_sources),) ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) - LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-micro + ifneq ($(filter libprotobuf-java-2.3.0-micro,$(LOCAL_STATIC_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on libprotobuf-java-2.3.0-micro in $(LOCAL_MODULE)) + LOCAL_STATIC_JAVA_LIBRARIES := $(filter-out libprotobuf-java-2.3.0-micro,$(LOCAL_STATIC_JAVA_LIBRARIES)) + endif + LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) - LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-nano + ifneq ($(filter libprotobuf-java-2.3.0-nano,$(LOCAL_STATIC_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on libprotobuf-java-2.3.0-nano in $(LOCAL_MODULE)) + LOCAL_STATIC_JAVA_LIBRARIES := $(filter-out libprotobuf-java-2.3.0-nano,$(LOCAL_STATIC_JAVA_LIBRARIES)) + endif + LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano else - LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-lite + ifneq ($(filter libprotobuf-java-2.3.0-lite,$(LOCAL_STATIC_JAVA_LIBRARIES)),) + $(warning Stripping unneeded dependency on libprotobuf-java-2.3.0-lite in $(LOCAL_MODULE)) + LOCAL_STATIC_JAVA_LIBRARIES := $(filter-out libprotobuf-java-2.3.0-lite,$(LOCAL_STATIC_JAVA_LIBRARIES)) + endif + LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite endif endif endif