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 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 ## 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 define filter-soong-makefiles
$(foreach mk,$(1),\ $(sort $(foreach mk,$(1),\
$(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(mk))),\ $(if $(filter %/Android.bp,$(mk)),\
$(if $(wildcard $(patsubst %/Android.mk,%/Android.soong.mk,$(mk))),\ $(call _filter-soong-bpfile,$(mk)),\
$(info skipping $(mk), but including Android.soong.mk ...)\ $(call _filter-soong-makefile,$(mk)))))
$(patsubst %/Android.mk,%/Android.soong.mk,$(mk)),\
$(info skipping $(mk) ...)),\
$(mk)))
endef endef
########################################################### ###########################################################
@@ -155,7 +171,7 @@ endef
########################################################### ###########################################################
define all-makefiles-under 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 endef
########################################################### ###########################################################
@@ -168,7 +184,7 @@ endef
define first-makefiles-under define first-makefiles-under
$(call filter-soong-makefiles,\ $(call filter-soong-makefiles,\
$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \ $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
--mindepth=2 $(1) Android.mk)) --mindepth=2 $(addprefix --dir=,$(1)) Android.bp Android.mk))
endef endef
########################################################### ###########################################################
@@ -188,8 +204,9 @@ endef
# $(1): List of directories to look for under this directory # $(1): List of directories to look for under this directory
define all-named-subdir-makefiles define all-named-subdir-makefiles
$(sort $(call filter-soong-makefiles,\ $(call filter-soong-makefiles,\
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1)))))) $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))\
$(wildcard $(addsuffix /Android.bp, $(addprefix $(call my-dir)/,$(1)))))
endef endef
########################################################### ###########################################################

View File

@@ -501,7 +501,6 @@ endif
# #
# Typical build; include any Android.mk files we can find. # Typical build; include any Android.mk files we can find.
# #
subdirs := $(TOP)
FULL_BUILD := true FULL_BUILD := true
@@ -542,12 +541,7 @@ ifneq ($(dont_bother),true)
# Include all of the makefiles in the system # Include all of the makefiles in the system
# #
# Can't use first-makefiles-under here because subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
# --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 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)))