Refactor calculation LOCAL_CHECKED_MODULE

To remove dup code;
Also added two more umbrella targets: host, target.

Change-Id: Ia6deed2940a26a31ad823fe54816840861f3fb72
This commit is contained in:
Ying Wang 2013-01-30 11:22:06 -08:00
parent ef1a9613cb
commit 1d977e3183
4 changed files with 28 additions and 21 deletions

View File

@ -531,6 +531,14 @@ ifndef LOCAL_CHECKED_MODULE
endif
endif
need_compile_java :=
ifdef java_alternative_checked_module
ifneq (,$(strip $(all_java_sources)$(full_static_java_libs))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)))
need_compile_java := true
LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
endif
endif
# If they request that this module not be checked, then don't.
# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
# GOOD REASON WILL HAVE IT REMOVED.
@ -585,8 +593,8 @@ ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
# it will default to recursive expansion.
$(foreach tag,$(LOCAL_MODULE_TAGS),\
$(eval ALL_MODULE_TAGS.$(tag) := \
$(ALL_MODULE_TAGS.$(tag)) \
$(LOCAL_INSTALLED_MODULE)))
$(ALL_MODULE_TAGS.$(tag)) \
$(LOCAL_INSTALLED_MODULE)))
# Add this module name to the tag list of each specified tag.
$(foreach tag,$(LOCAL_MODULE_TAGS),\
@ -595,18 +603,12 @@ $(foreach tag,$(LOCAL_MODULE_TAGS),\
###########################################################
## umbrella targets used to verify builds
###########################################################
check_build_target := $(LOCAL_CHECKED_MODULE)
j_or_n :=
ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
j_or_n := native
else
ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
j_or_n := java
# We don't want to verify the jni code when you just want to check the Java code.
# See LOCAL_CHECKED_MODULE in build/core/java.mk
ifneq (,$(strip $(all_java_sources)$(full_static_java_libs))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)))
check_build_target := $(full_classes_compiled_jar)
endif
endif
endif
ifdef LOCAL_IS_HOST_MODULE
@ -616,9 +618,9 @@ h_or_t := target
endif
ifdef j_or_n
$(j_or_n) $(j_or_n)-$(h_or_t) : $(check_build_target)
$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(check_build_target)
$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
endif
endif

View File

@ -43,10 +43,15 @@ LOCAL_INTERMEDIATE_TARGETS += \
$(built_dex)
LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
# See comment in java.mk
java_alternative_checked_module := $(full_classes_compiled_jar)
endif # LOCAL_BUILD_HOST_DEX
include $(BUILD_SYSTEM)/base_rules.mk
java_alternative_checked_module :=
# The layers file allows you to enforce a layering between java packages.
# Run build/tools/java-layers.py for more details.
layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))

View File

@ -234,6 +234,12 @@ LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
LOCAL_RESOURCE_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript/res $(LOCAL_RESOURCE_DIR)
endif
# All of the rules after full_classes_compiled_jar are very unlikely
# to fail except for bugs in their respective tools. If you would
# like to run these rules, add the "all" modifier goal to the make
# command line.
java_alternative_checked_module := $(full_classes_compiled_jar)
# TODO: It looks like the only thing we need from base_rules is
# all_java_sources. See if we can get that by adding a
# common_java.mk, and moving the include of base_rules.mk to
@ -243,6 +249,8 @@ endif
include $(BUILD_SYSTEM)/base_rules.mk
#######################################
java_alternative_checked_module :=
# We use intermediates.COMMON because the classes.jar/.dex files will be
# common even if LOCAL_BUILT_MODULE isn't.
#
@ -259,7 +267,8 @@ $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
# If the module includes java code (i.e., it's not framework-res), compile it.
full_classes_jar :=
built_dex :=
ifneq (,$(strip $(all_java_sources)$(full_static_java_libs))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)))
# need_compile_java is set in base_rules.mk
ifeq ($(need_compile_java),true)
# If LOCAL_BUILT_MODULE_STEM wasn't overridden by our caller,
# full_classes_jar will be the same module as LOCAL_BUILT_MODULE.
@ -301,15 +310,6 @@ $(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_ja
$(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-java-to-classes.jar)
# All of the rules after full_classes_compiled_jar are very unlikely
# to fail except for bugs in their respective tools. If you would
# like to run these rules, add the "all" modifier goal to the make
# command line.
# This overwrites the value defined in base_rules.mk. That's a little
# dirty. It's preferable to set LOCAL_CHECKED_MODULE, but this has to
# be done after the inclusion of base_rules.mk.
ALL_MODULES.$(LOCAL_MODULE).CHECKED := $(full_classes_compiled_jar)
$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g
# Run jarjar if necessary, otherwise just copy the file.

View File

@ -823,7 +823,7 @@ $(call dist-for-goals,sdk win_sdk, \
endif
# umbrella targets to assit engineers in verifying builds
.PHONY: java native java-host java-target native-host native-target \
.PHONY: java native target host java-host java-target native-host native-target \
java-host-tests java-target-tests native-host-tests native-target-tests \
java-tests native-tests host-tests target-tests
# some synonyms