Don't add dependencies on Makefiles when using ninja

Ninja has an implicit dependency on the command being run, and kati will
regenerate the ninja manifest if any read makefile changes, so there is no
need to have dependencies on makefiles.
This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't
include base_rules.mk, but it will fix the most common ones.

Bug: 23566977
Change-Id: I66de882421376303ab7233c8ce7274548f6b2199
This commit is contained in:
Colin Cross 2015-09-28 16:26:00 -07:00
parent 6c3bf1b800
commit a4447e8c89
13 changed files with 30 additions and 19 deletions

View File

@ -56,6 +56,16 @@ ifeq ($(my_host_cross),true)
my_module_tags := my_module_tags :=
endif endif
ifdef BUILDING_WITH_NINJA
# Ninja has an implicit dependency on the command being run, and kati will
# regenerate the ninja manifest if any read makefile changes, so there is no
# need to have dependencies on makefiles.
# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
# base_rules.mk, but it will fix the most common ones.
LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
endif
########################################################### ###########################################################
## Validate and define fallbacks for input LOCAL_* variables. ## Validate and define fallbacks for input LOCAL_* variables.
########################################################### ###########################################################

View File

@ -52,7 +52,7 @@ my_cxx_wrapper := $(CXX_WRAPPER)
my_c_includes := $(LOCAL_C_INCLUDES) my_c_includes := $(LOCAL_C_INCLUDES)
my_generated_sources := $(LOCAL_GENERATED_SOURCES) my_generated_sources := $(LOCAL_GENERATED_SOURCES)
my_native_coverage := $(LOCAL_NATIVE_COVERAGE) my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS) my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
ifdef LOCAL_IS_HOST_MODULE ifdef LOCAL_IS_HOST_MODULE
@ -1029,7 +1029,7 @@ import_includes_deps := $(strip \
$(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) $(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
$(import_includes) : $(LOCAL_MODULE_MAKEFILE) $(import_includes_deps) $(import_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(import_includes_deps)
@echo Import includes file: $@ @echo Import includes file: $@
$(hide) mkdir -p $(dir $@) && rm -f $@ $(hide) mkdir -p $(dir $@) && rm -f $@
ifdef import_includes_deps ifdef import_includes_deps
@ -1237,7 +1237,7 @@ $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
export_includes := $(intermediates)/export_includes export_includes := $(intermediates)/export_includes
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs) $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
# Make sure .pb.h are already generated before any dependent source files get compiled. # Make sure .pb.h are already generated before any dependent source files get compiled.
$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(proto_generated_headers) $(dbus_generated_headers) $(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers)
@echo Export includes file: $< -- $@ @echo Export includes file: $< -- $@
$(hide) mkdir -p $(dir $@) && rm -f $@ $(hide) mkdir -p $(dir $@) && rm -f $@
ifdef my_export_c_include_dirs ifdef my_export_c_include_dirs

View File

@ -132,6 +132,7 @@ endef
define my-dir define my-dir
$(strip \ $(strip \
$(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \ $(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
$(eval LOCAL_MODULE_MAKEFILE_DEP := $(if $(BUILDING_WITH_NINJA),,$$(LOCAL_MODULE_MAKEFILE))) \
$(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \ $(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
$(error my-dir must be called before including any other makefile.) \ $(error my-dir must be called before including any other makefile.) \
, \ , \

View File

@ -161,7 +161,7 @@ $(full_target): \
$(droiddoc) \ $(droiddoc) \
$(html_dir_files) \ $(html_dir_files) \
$(full_java_lib_deps) \ $(full_java_lib_deps) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
@echo Docs droiddoc: $(PRIVATE_OUT_DIR) @echo Docs droiddoc: $(PRIVATE_OUT_DIR)
$(hide) mkdir -p $(dir $@) $(hide) mkdir -p $(dir $@)

View File

@ -39,7 +39,7 @@ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
endif endif
endif endif
$(my_symlink): $(LOCAL_INSTALLED_MODULE) $(LOCAL_MODULE_MAKEFILE) $(my_symlink): $(LOCAL_INSTALLED_MODULE) $(LOCAL_MODULE_MAKEFILE_DEP)
@echo "Symlink: $@ -> $(PRIVATE_SRC_BINARY_NAME)" @echo "Symlink: $@ -> $(PRIVATE_SRC_BINARY_NAME)"
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
@rm -rf $@ @rm -rf $@

View File

@ -75,7 +75,7 @@ $(full_classes_compiled_jar): \
$(full_java_lib_deps) \ $(full_java_lib_deps) \
$(jar_manifest_file) \ $(jar_manifest_file) \
$(proto_java_sources_file_stamp) \ $(proto_java_sources_file_stamp) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-java-to-package) $(transform-host-java-to-package)
@ -124,8 +124,8 @@ endif
$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack) $(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
$(built_dex): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS) $(built_dex): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
$(built_dex): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \ $(built_dex): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
$(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE) \ $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_JAR) $(JACK_LAUNCHER_JAR) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_JAR) $(JACK_LAUNCHER_JAR)
@echo Building with Jack: $@ @echo Building with Jack: $@
$(jack-java-to-dex) $(jack-java-to-dex)

View File

@ -46,7 +46,7 @@ $(full_classes_jack): \
PRIVATE_JACK_INCREMENTAL_DIR := PRIVATE_JACK_INCREMENTAL_DIR :=
endif endif
$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \ $(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
$(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE) \ $(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
$(JACK_JAR) $(JACK_LAUNCHER_JAR) $(JACK_JAR) $(JACK_LAUNCHER_JAR)
@echo Building with Jack: $@ @echo Building with Jack: $@

View File

@ -88,6 +88,6 @@ $(full_classes_compiled_jar): \
$(full_java_lib_deps) \ $(full_java_lib_deps) \
$(jar_manifest_file) \ $(jar_manifest_file) \
$(proto_java_sources_file_stamp) \ $(proto_java_sources_file_stamp) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-java-to-package) $(transform-host-java-to-package)

View File

@ -44,7 +44,7 @@ $(LOCAL_BUILD_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
$(LOCAL_BUILT_MODULE): \ $(LOCAL_BUILT_MODULE): \
$(all_objects) \ $(all_objects) \
$(all_libraries) \ $(all_libraries) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-o-to-shared-lib) $(transform-host-o-to-shared-lib)

View File

@ -292,7 +292,7 @@ $(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_
$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \ $(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \
$(LOCAL_PATH)/%.aidl \ $(LOCAL_PATH)/%.aidl \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
$(AIDL) \ $(AIDL) \
$(aidl_preprocess_import) $(aidl_preprocess_import)
@ -400,7 +400,7 @@ $(full_classes_compiled_jar): \
$(layers_file) \ $(layers_file) \
$(RenderScript_file_stamp) \ $(RenderScript_file_stamp) \
$(proto_java_sources_file_stamp) \ $(proto_java_sources_file_stamp) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-java-to-classes.jar) $(transform-java-to-classes.jar)
@ -615,7 +615,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS)
jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \ jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
$(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) $(proguard_flag_files) \ $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) $(proguard_flag_files) \
$(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \ $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
$(LOCAL_MODULE_MAKEFILE) $(JACK_JAR) $(JACK_LAUNCHER_JAR) $(LOCAL_MODULE_MAKEFILE_DEP) $(JACK_JAR) $(JACK_LAUNCHER_JAR)
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
$(full_classes_jack): $(jack_all_deps) $(full_classes_jack): $(jack_all_deps)

View File

@ -7,7 +7,7 @@ LOCAL_MODULE_SUFFIX := -timestamp
include $(BUILD_SYSTEM)/base_rules.mk include $(BUILD_SYSTEM)/base_rules.mk
$(LOCAL_BUILT_MODULE): $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_BUILT_MODULE): $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(hide) echo "Fake: $@" $(hide) echo "Fake: $@"
$(hide) mkdir -p $(dir $@) $(hide) mkdir -p $(dir $@)
$(hide) touch $@ $(hide) touch $@

View File

@ -88,7 +88,7 @@ else # LOCAL_STRIP_MODULE and LOCAL_PACK_MODULE_RELOCATIONS not true
ifdef prebuilt_module_is_a_library ifdef prebuilt_module_is_a_library
export_includes := $(intermediates)/export_includes export_includes := $(intermediates)/export_includes
$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
$(export_includes) : $(LOCAL_MODULE_MAKEFILE) $(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP)
@echo Export includes file: $< -- $@ @echo Export includes file: $< -- $@
$(hide) mkdir -p $(dir $@) && rm -f $@ $(hide) mkdir -p $(dir $@) && rm -f $@
ifdef LOCAL_EXPORT_C_INCLUDE_DIRS ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
@ -304,12 +304,12 @@ endif # TARGET JAVA_LIBRARIES
ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
$(intermediates.COMMON)/classes.jack : PRIVATE_JILL_FLAGS:=$(LOCAL_JILL_FLAGS) $(intermediates.COMMON)/classes.jack : PRIVATE_JILL_FLAGS:=$(LOCAL_JILL_FLAGS)
$(intermediates.COMMON)/classes.jack : $(my_prebuilt_src_file) $(LOCAL_MODULE_MAKEFILE) \ $(intermediates.COMMON)/classes.jack : $(my_prebuilt_src_file) $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(JILL_JAR) $(JACK_JAR) $(JACK_LAUNCHER_JAR) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JILL_JAR) $(JACK_JAR) $(JACK_LAUNCHER_JAR)
$(transform-jar-to-jack) $(transform-jar-to-jack)
endif # JAVA_LIBRARIES endif # JAVA_LIBRARIES
$(built_module) : $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(built_module) : $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_prebuilt_src_file := my_prebuilt_src_file :=

View File

@ -80,7 +80,7 @@ $(linked_module): \
$(all_libraries) \ $(all_libraries) \
$(my_target_crtbegin_so_o) \ $(my_target_crtbegin_so_o) \
$(my_target_crtend_so_o) \ $(my_target_crtend_so_o) \
$(LOCAL_MODULE_MAKEFILE) \ $(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-o-to-shared-lib) $(transform-o-to-shared-lib)