am dedff62c: Merge "Contain obj of ../ source files in their intermediate dir."

* commit 'dedff62c8e44320dec8f667e27fdcd4cdff1430d':
  Contain obj of ../ source files in their intermediate dir.
This commit is contained in:
Ying Wang 2015-03-11 20:59:44 +00:00 committed by Android Git Automerger
commit 4e32ac8342
2 changed files with 127 additions and 16 deletions

View File

@ -640,16 +640,33 @@ endif
# we also do this on host modules, even though
# it's not really arm, because there are files that are shared.
cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources))
cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources))
cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
# For source files starting with ../, we remove all the ../ in the object file path,
# to avoid object file escaping the intermediate directory.
dotdot_arm_objects :=
$(foreach s,$(dotdot_arm_sources),\
$(eval $(call compile-dotdot-cpp-file,$(s),\
$(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
dotdot_arm_objects)))
dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
dotdot_objects :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-cpp-file,$(s),\
$(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
dotdot_objects)))
cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
$(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
$(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects)
@ -662,6 +679,8 @@ $(cpp_objects): $(intermediates)/%.o: \
-include $(cpp_objects:%.o=%.P)
endif
cpp_objects += $(dotdot_arm_objects) $(dotdot_objects)
###########################################################
## C++: Compile generated .cpp files to .o.
###########################################################
@ -718,16 +737,33 @@ gen_o_objects := $(filter %.o,$(my_generated_sources))
## C: Compile .c files to .o.
###########################################################
c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
dotdot_arm_sources := $(filter ../%,$(c_arm_sources))
c_arm_sources := $(filter-out ../%,$(c_arm_sources))
c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
c_normal_sources := $(filter %.c,$(my_src_files))
# For source files starting with ../, we remove all the ../ in the object file path,
# to avoid object file escaping the intermediate directory.
dotdot_arm_objects :=
$(foreach s,$(dotdot_arm_sources),\
$(eval $(call compile-dotdot-c-file,$(s),\
$(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
dotdot_arm_objects)))
dotdot_sources := $(filter ../%.c, $(my_src_files))
dotdot_objects :=
$(foreach s, $(dotdot_sources),\
$(eval $(call compile-dotdot-c-file,$(s),\
$(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
dotdot_objects)))
c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
$(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
$(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
c_objects := $(c_arm_objects) $(c_normal_objects)
@ -738,6 +774,8 @@ $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(pr
-include $(c_objects:%.o=%.P)
endif
c_objects += $(dotdot_arm_objects) $(dotdot_objects)
###########################################################
## C: Compile generated .c files to .o.
###########################################################
@ -775,8 +813,16 @@ endif
###########################################################
asm_sources_S := $(filter %.S,$(my_src_files))
dotdot_sources := $(filter ../%,$(asm_sources_S))
asm_sources_S := $(filter-out ../%,$(asm_sources_S))
asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
dotdot_objects_S :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file,$(s),\
$(my_additional_dependencies),\
dotdot_objects_S)))
ifneq ($(strip $(asm_objects_S)),)
$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
$(my_additional_dependencies)
@ -785,16 +831,23 @@ $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
endif
asm_sources_s := $(filter %.s,$(my_src_files))
dotdot_sources := $(filter ../%,$(asm_sources_s))
asm_sources_s := $(filter-out ../%,$(asm_sources_s))
asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
dotdot_objects_s :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file-no-deps,$(s),\
$(my_additional_dependencies),\
dotdot_objects_s)))
ifneq ($(strip $(asm_objects_s)),)
$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
$(my_additional_dependencies)
$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
-include $(asm_objects_s:%.o=%.P)
endif
asm_objects := $(asm_objects_S) $(asm_objects_s)
asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
# .asm for x86/x86_64 needs to be compiled with yasm.

View File

@ -1158,6 +1158,64 @@ $(transform-host-m-to-o-no-deps)
$(transform-d-to-p)
endef
###########################################################
## Rules to compile a single C/C++ source with ../ in the path
###########################################################
# Replace "../" in object paths with $(DOTDOT_REPLACEMENT).
DOTDOT_REPLACEMENT := dotdot/
## Rule to compile a C++ source file with ../ in the path.
## Must be called with $(eval).
# $(1): the C++ source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
define compile-dotdot-cpp-file
o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
$$(transform-$$(PRIVATE_HOST)cpp-to-o)
-include $$(o:%.o=%.P)
$(3) += $$(o)
endef
## Rule to compile a C source file with ../ in the path.
## Must be called with $(eval).
# $(1): the C source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
define compile-dotdot-c-file
o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
$$(transform-$$(PRIVATE_HOST)c-to-o)
-include $$(o:%.o=%.P)
$(3) += $$(o)
endef
## Rule to compile a .S source file with ../ in the path.
## Must be called with $(eval).
# $(1): the .S source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
define compile-dotdot-s-file
o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
$$(transform-$$(PRIVATE_HOST)s-to-o)
-include $$(o:%.o=%.P)
$(3) += $$(o)
endef
## Rule to compile a .s source file with ../ in the path.
## Must be called with $(eval).
# $(1): the .s source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
define compile-dotdot-s-file-no-deps
o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
$$(transform-$$(PRIVATE_HOST)s-to-o-no-deps)
$(3) += $$(o)
endef
###########################################################
## Commands for running ar
###########################################################