From 990cf5e57d5f3e454dd60f1d532f4dabe92a1b32 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 28 Aug 2013 13:04:46 -0700 Subject: [PATCH] Better handle of need_compile_java. Change-Id: I609a27e2b35b08962243b6516c6c525c0c938d3c --- core/base_rules.mk | 21 ++++++++++----------- core/java.mk | 36 +++++++++++++++++++----------------- core/package.mk | 3 +++ core/static_java_library.mk | 2 ++ 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 3d5f51df8..33bc6fd64 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -353,8 +353,11 @@ else endif # java_resource_file_groups ## PRIVATE java vars ###################################### - -ifneq ($(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)),) +# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, +# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. +# You have to set up the dependency in some other way. +need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)) +ifdef need_compile_java full_static_java_libs := \ $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ @@ -449,7 +452,7 @@ else $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := endif -endif # PRIVATE java vars +endif # need_compile_java ########################################################### @@ -547,20 +550,16 @@ endif # !LOCAL_UNINSTALLABLE_MODULE ## CHECK_BUILD goals ########################################################### +ifdef java_alternative_checked_module + LOCAL_CHECKED_MODULE := $(java_alternative_checked_module) +endif + # If nobody has defined a more specific module for the # checked modules, use LOCAL_BUILT_MODULE. ifndef LOCAL_CHECKED_MODULE LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE) 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. diff --git a/core/java.mk b/core/java.mk index 1c4558ff3..4814a9a8c 100644 --- a/core/java.mk +++ b/core/java.mk @@ -12,16 +12,6 @@ endif endif # !PDK_JAVA endif #PDK - -# Make sure there's something to build. -# It's possible to build a package that doesn't contain any classes. -# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, -# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. -# You have to set up the dependency in some other way. -ifeq (,$(strip $(LOCAL_SRC_FILES)$(all_res_assets)$(LOCAL_STATIC_JAVA_LIBRARIES))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))) -$(error $(LOCAL_PATH): Target java module does not define any source or resource files) -endif - LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES)) LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) @@ -117,9 +107,14 @@ full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf) built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf) full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar -# full_classes_jar and built_dex are cleared below, and re-set if we really need them. +ifeq ($(LOCAL_EXPORT_PACKAGE_RESOURCES),true) +# This is framework-res, we don't need to compile any Java code. +full_classes_jar := +built_dex := +else full_classes_jar := $(intermediates.COMMON)/classes.jar built_dex := $(intermediates.COMMON)/$(built_dex_leaf) +endif LOCAL_INTERMEDIATE_TARGETS += \ $(full_classes_compiled_jar) \ @@ -248,7 +243,11 @@ endif # 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. +ifdef full_classes_jar java_alternative_checked_module := $(full_classes_compiled_jar) +else +java_alternative_checked_module := +endif # 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 @@ -261,6 +260,13 @@ include $(BUILD_SYSTEM)/base_rules.mk java_alternative_checked_module := +# Make sure there's something to build. +ifdef full_classes_jar +ifndef need_compile_java +$(error $(LOCAL_PATH): Target java module does not define any source or resource files) +endif +endif + # Install the RS compatibility libraries to /system/lib/ if necessary ifdef rs_compatibility_jni_libs installed_rs_compatibility_jni_libs := $(addprefix $(TARGET_OUT_SHARED_LIBRARIES)/,\ @@ -296,11 +302,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): \ # properly. $(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 := -# need_compile_java is set in base_rules.mk -ifeq ($(need_compile_java),true) +ifdef full_classes_jar # If LOCAL_BUILT_MODULE_STEM wasn't overridden by our caller, # full_classes_jar will be the same module as LOCAL_BUILT_MODULE. @@ -505,4 +507,4 @@ $(findbugs_html) : $(findbugs_xml) $(LOCAL_MODULE)-findbugs : $(findbugs_html) -endif +endif # full_classes_jar is defined diff --git a/core/package.mk b/core/package.mk index ff202cb76..fd72cced8 100644 --- a/core/package.mk +++ b/core/package.mk @@ -480,3 +480,6 @@ lint-$(LOCAL_PACKAGE_NAME) : lintall : lint-$(LOCAL_PACKAGE_NAME) endif # skip_definition + +# Reset internal variables. +all_res_assets := diff --git a/core/static_java_library.mk b/core/static_java_library.mk index cdb98f01f..f95a382f7 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -126,4 +126,6 @@ endif endif # $(all_resources) not empty +# Reset internal variables. +all_res_assets := LOCAL_IS_STATIC_JAVA_LIBRARY := -- 2.11.0