forked from openkylin/platform_build
Support java annotation proccessors
The codebase is growing more uses of annotation processors,
through a mixture of LOCAL_ADDITIONAL_DEPENDENCIES and
LOCAL_JACK_FLAGS. Add LOCAL_ANNOTATION_PROCESSORS and handle
the rest in the build system.
For now we also need LOCAL_ANNOTATION_PROCESSOR_CLASSES to
work around bad behavior in grok (b/25860419).
Test: m -j java
Change-Id: I465b021e65d25ed3ea517333a82ec4ebd63fc038
(cherry picked from commit cde14987ba
)
This commit is contained in:
parent
9348d38d20
commit
e8ee68bb9b
|
@ -592,6 +592,17 @@ alphabetically.</p>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h4>LOCAL_ANNOTATION_PROCESSORS</h4>
|
||||||
|
<p>Set this to a list of modules built with <code>BUILD_HOST_JAVA_LIBRARY</code>
|
||||||
|
to have their jars passed to javac with -processorpath for use as annotation
|
||||||
|
processors.</p>
|
||||||
|
|
||||||
|
<h4>LOCAL_ANNOTATION_PROCESSOR_CLASSES</h4>
|
||||||
|
<p>Set this to a list of classes to be passed to javac as -processor arguments.
|
||||||
|
This list is would be unnecessary, as javac will autodetect annotation processor
|
||||||
|
classes, except that the Grok tool that is used on the Android source code
|
||||||
|
does not autodetect them and requires listing them manually.</p>
|
||||||
|
|
||||||
<h4>LOCAL_ASSET_FILES</h4>
|
<h4>LOCAL_ASSET_FILES</h4>
|
||||||
<p>In Android.mk files that <code>include $(BUILD_PACKAGE)</code> set this
|
<p>In Android.mk files that <code>include $(BUILD_PACKAGE)</code> set this
|
||||||
to the set of files you want built into your app. Usually:</p>
|
to the set of files you want built into your app. Usually:</p>
|
||||||
|
|
|
@ -12,6 +12,8 @@ LOCAL_ADDITIONAL_HTML_DIR:=
|
||||||
LOCAL_ADDITIONAL_JAVA_DIR:=
|
LOCAL_ADDITIONAL_JAVA_DIR:=
|
||||||
LOCAL_AIDL_INCLUDES:=
|
LOCAL_AIDL_INCLUDES:=
|
||||||
LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
|
LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
|
||||||
|
LOCAL_ANNOTATION_PROCESSORS:=
|
||||||
|
LOCAL_ANNOTATION_PROCESSOR_CLASSES:=
|
||||||
LOCAL_APK_LIBRARIES:=
|
LOCAL_APK_LIBRARIES:=
|
||||||
LOCAL_ARM_MODE:=
|
LOCAL_ARM_MODE:=
|
||||||
LOCAL_ASFLAGS:=
|
LOCAL_ASFLAGS:=
|
||||||
|
|
|
@ -2196,9 +2196,9 @@ endef
|
||||||
# $(2): bootclasspath
|
# $(2): bootclasspath
|
||||||
define compile-java
|
define compile-java
|
||||||
$(hide) rm -f $@
|
$(hide) rm -f $@
|
||||||
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
|
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
||||||
$(hide) mkdir -p $(dir $@)
|
$(hide) mkdir -p $(dir $@)
|
||||||
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
|
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
||||||
$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
|
$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
|
||||||
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list)
|
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list)
|
||||||
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
|
||||||
|
@ -2217,7 +2217,7 @@ $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; the
|
||||||
$(addprefix -classpath ,$(strip \
|
$(addprefix -classpath ,$(strip \
|
||||||
$(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
|
$(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
|
||||||
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
||||||
-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
|
-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
|
||||||
$(PRIVATE_JAVACFLAGS) \
|
$(PRIVATE_JAVACFLAGS) \
|
||||||
\@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
|
\@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
|
||||||
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
||||||
|
|
|
@ -86,7 +86,7 @@ $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
|
||||||
ifndef LOCAL_JACK_ENABLED
|
ifndef LOCAL_JACK_ENABLED
|
||||||
|
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
|
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
|
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
||||||
|
@ -96,6 +96,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(full_java_lib_deps) \
|
$(full_java_lib_deps) \
|
||||||
$(jar_manifest_file) \
|
$(jar_manifest_file) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(annotation_processor_deps) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
$(transform-host-java-to-package)
|
$(transform-host-java-to-package)
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
|
$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
|
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
||||||
|
@ -74,6 +74,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(full_java_lib_deps) \
|
$(full_java_lib_deps) \
|
||||||
$(jar_manifest_file) \
|
$(jar_manifest_file) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(annotation_processor_deps) \
|
||||||
$(NORMALIZE_PATH) \
|
$(NORMALIZE_PATH) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
$(transform-host-java-to-package)
|
$(transform-host-java-to-package)
|
||||||
|
|
|
@ -428,7 +428,7 @@ ifeq ($(RUN_ERROR_PRONE),true)
|
||||||
LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
|
LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
|
$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
|
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
|
||||||
|
@ -441,6 +441,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(layers_file) \
|
$(layers_file) \
|
||||||
$(RenderScript_file_stamp) \
|
$(RenderScript_file_stamp) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(annotation_processor_deps) \
|
||||||
$(NORMALIZE_PATH) \
|
$(NORMALIZE_PATH) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
$(transform-java-to-classes.jar)
|
$(transform-java-to-classes.jar)
|
||||||
|
@ -734,13 +735,14 @@ else # LOCAL_PROGUARD_ENABLED not defined
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS :=
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS :=
|
||||||
endif # LOCAL_PROGUARD_ENABLED defined
|
endif # LOCAL_PROGUARD_ENABLED defined
|
||||||
|
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS) $(annotation_processor_flags)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
|
||||||
|
|
||||||
jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
|
jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
|
||||||
$(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \
|
$(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \
|
||||||
$(common_proguard_flag_files) $(proguard_flag_files) \
|
$(common_proguard_flag_files) $(proguard_flag_files) \
|
||||||
$(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
|
$(proto_java_sources_file_stamp) $(annotation_processor_deps) \
|
||||||
|
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
|
||||||
$(NORMALIZE_PATH) $(JACK_DEFAULT_ARGS) $(JACK)
|
$(NORMALIZE_PATH) $(JACK_DEFAULT_ARGS) $(JACK)
|
||||||
|
|
||||||
$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
|
$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
|
||||||
|
|
|
@ -153,6 +153,20 @@ endif
|
||||||
need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
|
need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
|
||||||
ifdef need_compile_java
|
ifdef need_compile_java
|
||||||
|
|
||||||
|
annotation_processor_flags :=
|
||||||
|
annotation_processor_deps :=
|
||||||
|
|
||||||
|
ifdef LOCAL_ANNOTATION_PROCESSORS
|
||||||
|
annotation_processor_jars := $(call java-lib-deps,$(LOCAL_ANNOTATION_PROCESSORS),true)
|
||||||
|
annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars))
|
||||||
|
annotation_processor_deps += $(annotation_processor_jars)
|
||||||
|
|
||||||
|
# b/25860419: annotation processors must be explicitly specified for grok
|
||||||
|
annotation_processor_flags += $(foreach class,$(LOCAL_ANNOTATION_PROCESSOR_CLASSES),-processor $(class))
|
||||||
|
|
||||||
|
annotation_processor_jars :=
|
||||||
|
endif
|
||||||
|
|
||||||
full_static_java_libs := \
|
full_static_java_libs := \
|
||||||
$(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
|
$(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
|
||||||
$(call intermediates-dir-for, \
|
$(call intermediates-dir-for, \
|
||||||
|
@ -164,6 +178,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
|
||||||
|
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
|
||||||
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANNO_INTERMEDIATES_DIR := $(intermediates.COMMON)/anno
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true)
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true)
|
||||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto
|
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto
|
||||||
|
|
Loading…
Reference in New Issue