diff --git a/core/main.mk b/core/main.mk index 078aae5bdc..62870879c5 100644 --- a/core/main.mk +++ b/core/main.mk @@ -691,7 +691,14 @@ droidcore: files \ # The actual files built by the droidcore target changes depending # on the build variant. .PHONY: droid tests -droid tests: droidcore +ifeq ($(strip $(is_unbundled_app_build)),true) +# We build all modules in the source tree for an unbundled app build. +unbundled_build_modules := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS))) +droid: $(unbundled_build_modules) +else +droid: droidcore +endif +tests: droidcore # Dist for droid if droid is among the cmd goals, or no cmd goal is given. ifneq ($(filter droid,$(MAKECMDGOALS))$(filter ||,|$(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))|),) diff --git a/core/product.mk b/core/product.mk index be32e9eec3..7594f6f30d 100644 --- a/core/product.mk +++ b/core/product.mk @@ -29,13 +29,13 @@ $(shell test -d device && find device -maxdepth 6 -name AndroidProducts.mk) \ endef # -# Returns the sorted concatenation of all PRODUCT_MAKEFILES -# variables set in all AndroidProducts.mk files. -# $(call ) isn't necessary. +# Returns the sorted concatenation of PRODUCT_MAKEFILES +# variables set in the given AndroidProducts.mk files. +# $(1): the list of AndroidProducts.mk files. # -define get-all-product-makefiles +define get-product-makefiles $(sort \ - $(foreach f,$(_find-android-products-files), \ + $(foreach f,$(1), \ $(eval PRODUCT_MAKEFILES :=) \ $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \ $(eval include $(f)) \ @@ -46,6 +46,15 @@ $(sort \ ) endef +# +# Returns the sorted concatenation of all PRODUCT_MAKEFILES +# variables set in all AndroidProducts.mk files. +# $(call ) isn't necessary. +# +define get-all-product-makefiles +$(call get-product-makefiles,$(_find-android-products-files)) +endef + # # Functions for including product makefiles # diff --git a/core/product_config.mk b/core/product_config.mk index 02334cfa73..7e608f68c8 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -148,6 +148,27 @@ $(goal_name): $(MAKECMDGOALS) endif # else: Use the value set in the environment or buildspec.mk. +# --------------------------------------------------------------- +# Provide "APP-" targets, which lets you build +# an unbundled app. +# +unbundled_goals := $(strip $(filter APP-%,$(MAKECMDGOALS))) +ifdef unbundled_goals + ifneq ($(words $(unbundled_goals)),1) + $(error Only one APP-* goal may be specified; saw "$(unbundled_goals)")) + endif + UNBUNDLED_APP := $(patsubst APP-%,%,$(unbundled_goals)) + ifneq ($(filter $(DEFAULT_GOAL),$(MAKECMDGOALS)),) + MAKECMDGOALS := $(patsubst $(unbundled_goals),,$(MAKECMDGOALS)) + else + MAKECMDGOALS := $(patsubst $(unbundled_goals),$(DEFAULT_GOAL),$(MAKECMDGOALS)) + endif + is_unbundled_app_build := true + +.PHONY: $(unbundled_goals) +$(unbundled_goals): $(MAKECMDGOALS) +endif # unbundled_goals + # --------------------------------------------------------------- # Include the product definitions. # We need to do this to translate TARGET_PRODUCT into its @@ -157,12 +178,18 @@ include $(BUILD_SYSTEM)/node_fns.mk include $(BUILD_SYSTEM)/product.mk include $(BUILD_SYSTEM)/device.mk -# Read in all of the product definitions specified by the AndroidProducts.mk -# files in the tree. -# -#TODO: when we start allowing direct pointers to product files, -# guarantee that they're in this list. -$(call import-products, $(get-all-product-makefiles)) +ifeq ($(strip $(is_unbundled_app_build)),true) + # An unbundled app build needs only the core product makefiles. + $(call import-products,$(call get-product-makefiles,\ + $(SRC_TARGET_DIR)/product/AndroidProducts.mk)) +else + # Read in all of the product definitions specified by the AndroidProducts.mk + # files in the tree. + # + #TODO: when we start allowing direct pointers to product files, + # guarantee that they're in this list. + $(call import-products, $(get-all-product-makefiles)) +endif # is_unbundled_app_build $(check-all-products) #$(dump-products) #$(error done) diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk index 60b4c9b34a..7798ea1eb3 100644 --- a/target/product/AndroidProducts.mk +++ b/target/product/AndroidProducts.mk @@ -25,6 +25,12 @@ # it includes. # +ifeq ($(strip $(is_unbundled_app_build)),true) +# An unbundled app build needs only generic.mk. +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/core.mk \ + $(LOCAL_DIR)/generic.mk +else PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/core.mk \ $(LOCAL_DIR)/generic.mk \ @@ -33,3 +39,4 @@ PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/sdk.mk \ $(LOCAL_DIR)/sim.mk \ $(LOCAL_DIR)/large_emu_hw.mk +endif