Support build rules which generate .o files.
webviewchromium has some build rules which use a custom tool to create
.o files from other input (i.e. they are not prebuilt and so can't be
included in LOCAL_PREBUILT_OBJ_FILES). Support adding .o files to
LOCAL_GENERATED_SOURCES and doing the right thing with them (including
them in the static/dynamic library or executable being built).
Bug: 7714333
Change-Id: I3b1d29eeff30aebeafe33398f9bef2eb6972d997
diff --git a/core/binary.mk b/core/binary.mk
index 18f67fe..dd68fee 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -500,6 +500,12 @@
gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
###########################################################
+## o: Include generated .o files in output.
+###########################################################
+
+gen_o_objects := $(filter %.o,$(LOCAL_GENERATED_SOURCES))
+
+###########################################################
## C: Compile .c files to .o.
###########################################################
@@ -624,7 +630,8 @@
$(yacc_objects) \
$(lex_objects) \
$(proto_generated_objects) \
- $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
+ $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) \
+ $(gen_o_objects)
LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates)
@@ -632,7 +639,9 @@
LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
endif
-$(all_objects) : | $(LOCAL_GENERATED_SOURCES) $(import_includes)
+# .o files need to be filtered out of LOCAL_GENERATED_SOURCES
+# to avoid creating circular dependencies.
+$(all_objects) : | $(filter-out %.o,$(LOCAL_GENERATED_SOURCES)) $(import_includes)
ALL_C_CPP_ETC_OBJECTS += $(all_objects)
###########################################################