Update Android.mk finder to work with Android.bp files

The Android.mk finder should stop traversing when it finds an Android.bp
file, and any Android.soong.mk file at the same path should be included.

Update filter-soong-makefiles to accept a mixed list of Android.bp files
and Android.mk files, convert Android.bp files to Android.soong.mk files
if they exist, and ignore Android.mk files that have an Android.bp file.

Update first-makefiles-under to use the new --dir syntax for
findleaves.py and search for both Android.bp and Android.mk files.

Update all-makefiles-under and all-named-subdir-makefiles to search for
both Android.bp and Android.mk files.

Change-Id: Iddc51bf84593d5de3add02f2b2c065da08962af4
This commit is contained in:
Colin Cross
2016-05-27 15:23:13 -07:00
parent 40623e2a99
commit 4cbf8eb9f5
2 changed files with 30 additions and 19 deletions

View File

@@ -137,17 +137,33 @@ $(strip \
)
endef
define _filter-soong-makefile
$(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(1))),\
$(info skipping $(1) ...)\
$(call _filter-soong-bpfile $(patsubst %/Android.mk,%/Android.bp,$(1))),\
$(1))
endef
define _filter-soong-bpfile
$(if $(wildcard $(patsubst %/Android.bp,%/Android.soong.mk,$(1))),\
$(patsubst %/Android.bp,%/Android.soong.mk,$(1)))
endef
###########################################################
## Remove any makefiles that are being handled by soong
##
## If passed an Android.mk file, returns the Android.mk file
## if no Android.bp file exists and the same path. If an
## Android.bp file exists, or if passed an Android.bp file,
## returns the Android.soong.mk file at the same path if it
## exists, or nothing if it does not.
###########################################################
define filter-soong-makefiles
$(foreach mk,$(1),\
$(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(mk))),\
$(if $(wildcard $(patsubst %/Android.mk,%/Android.soong.mk,$(mk))),\
$(info skipping $(mk), but including Android.soong.mk ...)\
$(patsubst %/Android.mk,%/Android.soong.mk,$(mk)),\
$(info skipping $(mk) ...)),\
$(mk)))
$(sort $(foreach mk,$(1),\
$(if $(filter %/Android.bp,$(mk)),\
$(call _filter-soong-bpfile,$(mk)),\
$(call _filter-soong-makefile,$(mk)))))
endef
###########################################################
@@ -155,7 +171,7 @@ endef
###########################################################
define all-makefiles-under
$(sort $(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk)))
$(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk $(1)/*/Android.bp))
endef
###########################################################
@@ -168,7 +184,7 @@ endef
define first-makefiles-under
$(call filter-soong-makefiles,\
$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
--mindepth=2 $(1) Android.mk))
--mindepth=2 $(addprefix --dir=,$(1)) Android.bp Android.mk))
endef
###########################################################
@@ -188,8 +204,9 @@ endef
# $(1): List of directories to look for under this directory
define all-named-subdir-makefiles
$(sort $(call filter-soong-makefiles,\
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))))
$(call filter-soong-makefiles,\
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))\
$(wildcard $(addsuffix /Android.bp, $(addprefix $(call my-dir)/,$(1)))))
endef
###########################################################

View File

@@ -501,7 +501,6 @@ endif
#
# Typical build; include any Android.mk files we can find.
#
subdirs := $(TOP)
FULL_BUILD := true
@@ -542,14 +541,9 @@ ifneq ($(dont_bother),true)
# Include all of the makefiles in the system
#
# Can't use first-makefiles-under here because
# --mindepth=2 makes the prunes not work.
subdir_makefiles := \
$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) $(subdirs) Android.mk)
subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
subdir_makefiles := $(SOONG_ANDROID_MK) $(call filter-soong-makefiles,$(subdir_makefiles))
$(foreach mk, $(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
$(foreach mk,$(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
ifdef PDK_FUSION_PLATFORM_ZIP
# Bring in the PDK platform.zip modules.