Merge "Build from source or prebuilt"

This commit is contained in:
Ying Wang 2012-12-14 14:52:16 -08:00 committed by Android (Google) Code Review
commit 3a990aee1e
6 changed files with 84 additions and 22 deletions

View file

@ -130,6 +130,7 @@ LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true
# Don't delete the META_INF dir when merging static Java libraries.
LOCAL_DONT_DELETE_JAR_META_INF:=
LOCAL_ADDITIONAL_CERTIFICATES:=
LOCAL_PREBUILT_MODULE_FILE:=
# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
# iterate over thousands of entries every time.

View file

@ -2110,6 +2110,30 @@ $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3)
$(6): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
endef
## Whether to build from source if prebuilt alternative exists
###########################################################
# $(1): module name
# $(2): LOCAL_PATH
# Expands to empty string if not from source.
ifeq (true,$(ANDROID_BUILD_FROM_SOURCE))
define if-build-from-source
true
endef
else
define if-build-from-source
$(if $(filter $(ANDROID_NO_PREBUILT_MODULES),$(1))$(filter \
$(addsuffix %,$(ANDROID_NO_PREBUILT_PATHS)),$(2)),true)
endef
endif
# Include makefile $(1) if build from source for module $(2)
# $(1): the makefile to include
# $(2): module name
# $(3): LOCAL_PATH
define include-if-build-from-source
$(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1)))
endef
###########################################################
## Other includes
###########################################################

View file

@ -13,7 +13,21 @@ ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
LOCAL_MODULE_SUFFIX := $(HOST_EXECUTABLE_SUFFIX)
endif
$(call host-executable-hook)
skip_build_from_source :=
ifdef LOCAL_PREBUILT_MODULE_FILE
ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
include $(BUILD_PREBUILT)
skip_build_from_source := true
endif
endif
ifndef skip_build_from_source
include $(BUILD_SYSTEM)/binary.mk
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
$(transform-host-o-to-executable)
endif # skip_build_from_source

View file

@ -22,6 +22,18 @@ ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
$(error $(LOCAL_PATH): Cannot set module stem for a library)
endif
$(call host-shared-library-hook)
skip_build_from_source :=
ifdef LOCAL_PREBUILT_MODULE_FILE
ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
include $(BUILD_PREBUILT)
skip_build_from_source := true
endif
endif
ifndef skip_build_from_source
# Put the built modules of all shared libraries in a common directory
# to simplify the link line.
OVERRIDE_BUILT_MODULE_PATH := $(HOST_OUT_INTERMEDIATE_LIBRARIES)
@ -30,3 +42,5 @@ include $(BUILD_SYSTEM)/binary.mk
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-o-to-shared-lib)
endif # skip_build_from_source

View file

@ -84,6 +84,24 @@ include $(BUILD_SYSTEM)/config.mk
# be generated correctly
include $(BUILD_SYSTEM)/cleanbuild.mk
# These targets are going to delete stuff, don't bother including
# the whole directory tree if that's all we're going to do
ifeq ($(MAKECMDGOALS),clean)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),clobber)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),dataclean)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),installclean)
dont_bother := true
endif
# Include the google-specific config
-include vendor/google/build/config.mk
VERSION_CHECK_SEQUENCE_NUMBER := 3
-include $(OUT_DIR)/versions_checked.mk
ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
@ -387,21 +405,6 @@ ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
endif
# These targets are going to delete stuff, don't bother including
# the whole directory tree if that's all we're going to do
ifeq ($(MAKECMDGOALS),clean)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),clobber)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),dataclean)
dont_bother := true
endif
ifeq ($(MAKECMDGOALS),installclean)
dont_bother := true
endif
# Bring in all modules that need to be built.
ifneq ($(dont_bother),true)

View file

@ -16,6 +16,12 @@ ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
endif
ifdef LOCAL_PREBUILT_MODULE_FILE
my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
else
my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
endif
ifdef LOCAL_IS_HOST_MODULE
my_prefix := HOST_
else
@ -73,7 +79,7 @@ else
endif
$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
endif
endif # prebuilt_module_is_a_library
endif
PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
@ -95,7 +101,7 @@ ifeq ($(LOCAL_CERTIFICATE),)
ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
# It is now a build error to add a prebuilt .apk without
# specifying a key for it.
$(error No LOCAL_CERTIFICATE specified for prebuilt "$(LOCAL_SRC_FILES)")
$(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
endif
else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
# The magic string "PRESIGNED" means this package is already checked
@ -123,21 +129,21 @@ endif
ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
# Ensure that presigned .apks have been aligned.
$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ZIPALIGN)
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
$(transform-prebuilt-to-target-with-zipalign)
else
# Sign and align non-presigned .apks.
$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
$(transform-prebuilt-to-target)
$(sign-package)
$(align-package)
endif
else
ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
$(built_module) : $(my_prebuilt_src_file)
$(transform-prebuilt-to-target-strip-comments)
else
$(built_module) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
$(built_module) : $(my_prebuilt_src_file) | $(ACP)
$(transform-prebuilt-to-target)
ifneq ($(prebuilt_module_is_a_library),)
ifneq ($(LOCAL_IS_HOST_MODULE),)
@ -157,7 +163,7 @@ ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar
common_javalib_jar := $(dir $(common_classes_jar))javalib.jar
$(common_classes_jar) : $(LOCAL_PATH)/$(LOCAL_SRC_FILES) | $(ACP)
$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP)
$(transform-prebuilt-to-target)
$(common_javalib_jar) : $(common_classes_jar) | $(ACP)