Merge "Use dependency files generated by llvm-rs-cc"

This commit is contained in:
Shinichiro Hamaji 2016-01-26 06:36:02 +00:00 committed by Gerrit Code Review
commit 19f99a742d
2 changed files with 38 additions and 9 deletions

View file

@ -562,7 +562,7 @@ $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIP
$(transform-renderscripts-to-cpp-and-bc)
# include the dependency files (.d/.P) generated by llvm-rs-cc.
-include $(bc_dep_files:%.d=%.P)
$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp))
LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
@ -741,12 +741,8 @@ aidl_gen_include_root := $(intermediates)/aidl-generated/include
# Thus we'll actually generate source for each architecture.
$(foreach s,$(aidl_src),\
$(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
ifeq ($(BUILDING_WITH_NINJA),true)
$(foreach cpp,$(aidl_gen_cpp), \
$(eval $(cpp) : .KATI_DEPFILE := $(addsuffix .aidl.P,$(basename $(cpp)))))
else
-include $(addsuffix .aidl.P,$(basename $(aidl_gen_cpp)))
endif
$(call include-depfile,$(addsuffix .aidl.P,$(basename $(cpp))),$(cpp)))
$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)

View file

@ -874,7 +874,7 @@ endef
endif
###########################################################
## Commands for munging the dependency files GCC generates
## Commands for munging the dependency files the compiler generates
###########################################################
# $(1): the input .d file
# $(2): the output .P file
@ -889,6 +889,21 @@ define transform-d-to-p
$(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P))
endef
###########################################################
## Commands for including the dependency files the compiler generates
###########################################################
# $(1): the .P file
# $(2): the main build target
ifeq ($(BUILDING_WITH_NINJA),true)
define include-depfile
$(eval $(2) : .KATI_DEPFILE := $1)
endef
else
define include-depfile
$(eval -include $1)
endef
endif
###########################################################
## Commands for running lex
###########################################################
@ -954,6 +969,24 @@ endef
## Commands to compile RenderScript to C++
###########################################################
## Merge multiple .d files generated by llvm-rs-cc. This is necessary
## because ninja can handle only a single depfile per build target.
## We assume .d files start with two targets and their prerequisites
## follow. The first line is for the stamp file and the second line is
## for .bc file. There's no way to let ninja know dependencies to .bc
## files, so we give up build targets for .bc files. As we write the
## .stamp file as the target by ourselves, the sed script removes the
## first two lines and append a backslash to the last line to
## concatenate contents of multiple files.
# $(1): .d files to be merged
# $(2): merged .d file
define _merge-renderscript-d
$(hide) echo '$@: $(backslash)' > $2
$(foreach d,$1, \
$(hide) sed '1d; 2d; s/\( \\\)\?$$/ \\/' $d >> $2$(newline))
$(hide) echo >> $2
endef
define transform-renderscripts-to-cpp-and-bc
@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
@ -967,8 +1000,8 @@ $(hide) $(PRIVATE_RS_CC) \
$(PRIVATE_RS_FLAGS) \
$(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
$(PRIVATE_RS_SOURCE_FILES)
$(foreach d,$(PRIVATE_DEP_FILES),\
$(call transform-d-to-p-args,$(d),$(d:%.d=%.P))$(newline))
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
$(call transform-d-to-p-args,$@.d,$@.P)
$(hide) mkdir -p $(dir $@)
$(hide) touch $@
endef