Merge "Clean generated source dir if .proto/.rs is gonee."

This commit is contained in:
Ying Wang 2016-03-02 19:01:28 +00:00 committed by Gerrit Code Review
commit 591fa1284a
2 changed files with 31 additions and 23 deletions

View File

@ -46,6 +46,8 @@ $(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
$(call transform-proto-to-java) $(call transform-proto-to-java)
#TODO: protoc should output the dependencies introduced by imports. #TODO: protoc should output the dependencies introduced by imports.
ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath)
endif # proto_sources endif # proto_sources
######################################### #########################################
@ -264,6 +266,9 @@ $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_
ifdef aidl_sources ifdef aidl_sources
ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources) ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources)
endif endif
ifdef renderscript_sources
ALL_MODULES.$(my_register_name).RS_FILES := $(renderscript_sources_fullpath)
endif
endif # !LOCAL_IS_HOST_MODULE endif # !LOCAL_IS_HOST_MODULE
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs) $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs)

View File

@ -54,27 +54,30 @@ current_package_overlay_config :=
current_all_packages_config := current_all_packages_config :=
####################################################### #######################################################
# Check if we need to delete obsolete aidl-generated java files. # Check if we need to delete obsolete generated java files.
# When an aidl file gets deleted (or renamed), the generated java file is obsolete. # When an aidl/proto/etc file gets deleted (or renamed), the generated java file is obsolete.
previous_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_aidl_config.mk previous_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_gen_java_config.mk
current_aidl_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_aidl_config.mk current_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_gen_java_config.mk
$(shell rm -rf $(current_aidl_config) \ $(shell rm -rf $(current_gen_java_config) \
&& mkdir -p $(dir $(current_aidl_config))\ && mkdir -p $(dir $(current_gen_java_config))\
&& touch $(current_aidl_config)) && touch $(current_gen_java_config))
-include $(previous_aidl_config) -include $(previous_gen_java_config)
intermediates_to_clean := intermediates_to_clean :=
modules_with_aidl_files := modules_with_gen_java_files :=
$(foreach p, $(ALL_MODULES), \ $(foreach p, $(ALL_MODULES), \
$(if $(ALL_MODULES.$(p).AIDL_FILES),\ $(eval gs := $(strip $(ALL_MODULES.$(p).AIDL_FILES)\
$(eval modules_with_aidl_files += $(p))\ $(ALL_MODULES.$(p).PROTO_FILES)\
$(shell echo 'AIDL_FILES.$(p) := $(ALL_MODULES.$(p).AIDL_FILES)' >> $(current_aidl_config)))\ $(ALL_MODULES.$(p).RS_FILES)))\
$(if $(filter-out $(ALL_MODULES.$(p).AIDL_FILES),$(AIDL_FILES.$(p))),\ $(if $(gs),\
$(eval modules_with_gen_java_files += $(p))\
$(shell echo 'GEN_SRC_FILES.$(p) := $(gs)' >> $(current_gen_java_config)))\
$(if $(filter-out $(gs),$(GEN_SRC_FILES.$(p))),\
$(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR)))) $(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR))))
intermediates_to_clean := $(strip $(intermediates_to_clean)) intermediates_to_clean := $(strip $(intermediates_to_clean))
ifdef intermediates_to_clean ifdef intermediates_to_clean
$(info *** Obsolete aidl-generated files detected, clean intermediate files...) $(info *** Obsolete generated java files detected, clean intermediate files...)
$(info *** rm -rf $(intermediates_to_clean)) $(info *** rm -rf $(intermediates_to_clean))
$(shell rm -rf $(intermediates_to_clean)) $(shell rm -rf $(intermediates_to_clean))
intermediates_to_clean := intermediates_to_clean :=
@ -82,15 +85,15 @@ endif
# For modules not loaded by the current build (e.g. you are running mm/mmm), # For modules not loaded by the current build (e.g. you are running mm/mmm),
# we copy the info from the previous bulid. # we copy the info from the previous bulid.
$(foreach p, $(filter-out $(ALL_MODULES),$(MODULES_WITH_AIDL_FILES)),\ $(foreach p, $(filter-out $(ALL_MODULES),$(MODULES_WITH_GEN_JAVA_FILES)),\
$(shell echo 'AIDL_FILES.$(p) := $(AIDL_FILES.$(p))' >> $(current_aidl_config))) $(shell echo 'GEN_SRC_FILES.$(p) := $(GEN_SRC_FILES.$(p))' >> $(current_gen_java_config)))
MODULES_WITH_AIDL_FILES := $(sort $(MODULES_WITH_AIDL_FILES) $(modules_with_aidl_files)) MODULES_WITH_GEN_JAVA_FILES := $(sort $(MODULES_WITH_GEN_JAVA_FILES) $(modules_with_gen_java_files))
$(shell echo 'MODULES_WITH_AIDL_FILES := $(MODULES_WITH_AIDL_FILES)' >> $(current_aidl_config)) $(shell echo 'MODULES_WITH_GEN_JAVA_FILES := $(MODULES_WITH_GEN_JAVA_FILES)' >> $(current_gen_java_config))
# Now current becomes previous. # Now current becomes previous.
$(shell cmp $(current_aidl_config) $(previous_aidl_config) > /dev/null 2>&1 || mv -f $(current_aidl_config) $(previous_aidl_config)) $(shell cmp $(current_gen_java_config) $(previous_gen_java_config) > /dev/null 2>&1 || mv -f $(current_gen_java_config) $(previous_gen_java_config))
MODULES_WITH_AIDL_FILES := MODULES_WITH_GEN_JAVA_FILES :=
modules_with_aidl_files := modules_with_gen_java_files :=
previous_aidl_config := previous_gen_java_config :=
current_aidl_config := current_gen_java_config :=