Refactor how MODULES-IN-* is defined

Unlike the previous performance patches, this does change the ninja
file, shrinking build-aosp_crosshatch.ninja on aosp-master from 393MB to
387MB, while reducing kati runtime from 28.6s to 27.7s.

Previously, MODULES-IN-art would depend on every target defined under
art/***. After this change, it only depends on the modules names that
were directly defined under it, and depends on the MODULES-IN-art-*
for its subfolders.

Bug: 158488548
Test: mmma system/core/adb
Test: mmma system/core
Change-Id: Idfe80f707738faae4777e0d6dc9fd08014775696
This commit is contained in:
Dan Willemsen
2020-06-08 23:10:14 -07:00
parent 397972fa6a
commit 343caec30c

View File

@@ -452,12 +452,33 @@ endif
# Set up phony targets that covers all modules under the given paths. # Set up phony targets that covers all modules under the given paths.
# This allows us to build everything in given paths by running mmma/mma. # This allows us to build everything in given paths by running mmma/mma.
my_path_components := $(subst /,$(space),$(LOCAL_PATH)) define my_path_comp
my_path_prefix := MODULES-IN parent := $(patsubst %/,%,$(dir $(1)))
$(foreach c, $(my_path_components),\ parent_target := MODULES-IN-$$(subst /,-,$$(parent))
$(eval my_path_prefix := $(my_path_prefix)-$(c))\ .PHONY: $$(parent_target)
$(eval .PHONY : $(my_path_prefix))\ $$(parent_target): $(2)
$(eval $(my_path_prefix) : $(my_all_targets))) ifndef $$(parent_target)
$$(parent_target) := true
ifneq (,$$(findstring /,$$(parent)))
$$(eval $$(call my_path_comp,$$(parent),$$(parent_target)))
endif
endif
endef
_local_path := $(patsubst %/,%,$(LOCAL_PATH))
_local_path_target := MODULES-IN-$(subst /,-,$(_local_path))
.PHONY: $(_local_path_target)
$(_local_path_target): $(my_register_name)
ifndef $(_local_path_target)
$(_local_path_target) := true
$(eval $(call my_path_comp,$(_local_path),$(_local_path_target)))
endif
_local_path :=
_local_path_target :=
my_path_comp :=
########################################################### ###########################################################
## Module installation rule ## Module installation rule