Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 343caec3 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

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
parent 397972fa
Loading
Loading
Loading
Loading
+27 −6
Original line number Diff line number Diff line
@@ -452,12 +452,33 @@ endif

# 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.
my_path_components := $(subst /,$(space),$(LOCAL_PATH))
my_path_prefix := MODULES-IN
$(foreach c, $(my_path_components),\
  $(eval my_path_prefix := $(my_path_prefix)-$(c))\
  $(eval .PHONY : $(my_path_prefix))\
  $(eval $(my_path_prefix) : $(my_all_targets)))
define my_path_comp
parent := $(patsubst %/,%,$(dir $(1)))
parent_target := MODULES-IN-$$(subst /,-,$$(parent))
.PHONY: $$(parent_target)
$$(parent_target): $(2)
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