From 46e9beca50057bd4ff375b35fd5958c05ce5bcb7 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 27 May 2009 19:41:07 -0700 Subject: [PATCH] core: Add support for static libraries to include other whole static libs. Currently, if LOCAL_WHOLE_STATIC_LIBRARIES is specified, its values is ignored. This patch addresses this limitation and works as follows: For every whole lib specified, it extracts the archive into a sub-directory under the target lib's intermediate, and then seeds the initial target archive with all the members. Signed-off-by: Dima Zavin --- core/base_rules.mk | 3 ++- core/definitions.mk | 18 +++++++++++++++++- core/static_library.mk | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 4ee2985ec..c182a779e 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -267,7 +267,6 @@ full_static_java_libs := \ JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/javalib.jar) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE)) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INTERMEDIATES_DIR := $(intermediates) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources) @@ -357,6 +356,8 @@ $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) + # Tell the module and all of its sub-modules who it is. $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(LOCAL_MODULE) diff --git a/core/definitions.mk b/core/definitions.mk index 069855d8f..f3382c3a0 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -904,12 +904,28 @@ endef ## Commands for running ar ########################################################### +define extract-and-include-whole-static-libs +$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ + @echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \ + ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\ + rm -rf $$ldir; \ + mkdir -p $$ldir; \ + filelist=; \ + for f in `$(TARGET_AR) t $(lib)`; do \ + $(TARGET_AR) p $(lib) $$f > $$ldir/$$f; \ + filelist="$$filelist $$ldir/$$f"; \ + done ; \ + $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\ +) +endef + # Explicitly delete the archive first so that ar doesn't # try to add to an existing archive. define transform-o-to-static-lib @mkdir -p $(dir $@) -@echo "target StaticLib: $(PRIVATE_MODULE) ($@)" @rm -f $@ +$(extract-and-include-whole-static-libs) +@echo "target StaticLib: $(PRIVATE_MODULE) ($@)" $(hide) $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $^ endef diff --git a/core/static_library.mk b/core/static_library.mk index 252dfd092..2138e469b 100644 --- a/core/static_library.mk +++ b/core/static_library.mk @@ -25,5 +25,6 @@ $(all_objects) : TARGET_GLOBAL_CFLAGS := $(all_objects) : TARGET_GLOBAL_CPPFLAGS := endif +$(LOCAL_BUILT_MODULE): $(built_whole_libraries) $(LOCAL_BUILT_MODULE): $(all_objects) $(transform-o-to-static-lib)