Data-binding integration.
- Set up LOCAL_JAVACFLAGS to run annotation processing. - Set up a new intermediate directory $(data_binding_intermediates) to contain data-binding intermediate files. - The annotation generated code is generated to $(data_binding_intermediates)/anno-src. The code will be automatically included by javac, so no need to store it in $(LOCAL_INTERMEDIATE_SOURCE_DIR). - Set up rules to run DATA_BINDING_COMPILER. The generated code will be put in $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding, so that it can be automatically included by $(compile-java); Other generated files are put in in subdirs of $(data_binding_intermediates). The generated resource dir replaces the app's original LOCAL_RESOURCE_DIR. Also fixed transform-jar-to-jack on prebuilt aar. Bug: 19945740 Change-Id: I42d9b0e5cd48cf2dce4488298a960b3c95602beb
This commit is contained in:
parent
0b7565be15
commit
ed0361f1d3
|
@ -548,7 +548,7 @@ ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
|
|||
LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
|
||||
endif
|
||||
|
||||
ifndef LOCAL_UNINSTALLABLE_MODULE
|
||||
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
|
||||
# Define a copy rule to install the module.
|
||||
# acp and libraries that it uses can't use acp for
|
||||
# installation; hence, LOCAL_ACP_UNAVAILABLE.
|
||||
|
|
|
@ -182,6 +182,7 @@ LOCAL_DPI_VARIANTS:=
|
|||
LOCAL_DPI_FILE_STEM:=
|
||||
LOCAL_SANITIZE:=
|
||||
LOCAL_SANITIZE_RECOVER:=
|
||||
LOCAL_DATA_BINDING:=
|
||||
|
||||
# arch specific variables
|
||||
LOCAL_SRC_FILES_$(TARGET_ARCH):=
|
||||
|
|
|
@ -420,6 +420,7 @@ MKTARBALL := build/tools/mktarball.sh
|
|||
TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
|
||||
E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
|
||||
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
|
||||
DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
|
||||
|
||||
ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
|
||||
DEFAULT_JACK_ENABLED:=full
|
||||
|
|
|
@ -204,6 +204,24 @@ endif # LOCAL_EMMA_INSTRUMENT
|
|||
|
||||
rs_compatibility_jni_libs :=
|
||||
|
||||
ifeq ($(LOCAL_DATA_BINDING),true)
|
||||
data_binding_intermediates := $(intermediates.COMMON)/data-binding
|
||||
|
||||
LOCAL_JAVACFLAGS += -processorpath $(DATA_BINDING_COMPILER) -s $(data_binding_intermediates)/anno-src
|
||||
LOCAL_JACK_FLAGS += --processorpath $(DATA_BINDING_COMPILER)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES += databinding-baselibrary
|
||||
LOCAL_STATIC_JAVA_AAR_LIBRARIES += databinding-library databinding-adapters
|
||||
|
||||
data_binding_res_in := $(LOCAL_RESOURCE_DIR)
|
||||
data_binding_res_out := $(data_binding_intermediates)/res
|
||||
|
||||
# Replace with the processed merged res dir.
|
||||
LOCAL_RESOURCE_DIR := $(data_binding_res_out)
|
||||
|
||||
LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library
|
||||
endif # LOCAL_DATA_BINDING
|
||||
|
||||
include $(BUILD_SYSTEM)/android_manifest.mk
|
||||
|
||||
#################################
|
||||
|
@ -225,6 +243,34 @@ $(LOCAL_INTERMEDIATE_TARGETS): \
|
|||
PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
|
||||
endif
|
||||
|
||||
ifeq ($(LOCAL_DATA_BINDING),true)
|
||||
data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp
|
||||
$(data_binding_stamp): PRIVATE_INTERMEDIATES := $(data_binding_intermediates)
|
||||
$(data_binding_stamp): PRIVATE_MANIFEST := $(full_android_manifest)
|
||||
# Generate code into $(LOCAL_INTERMEDIATE_SOURCE_DIR) so that the generated .java files
|
||||
# will be automatically picked up by function compile-java.
|
||||
$(data_binding_stamp): PRIVATE_SRC_OUT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding
|
||||
$(data_binding_stamp): PRIVATE_XML_OUT := $(data_binding_intermediates)/xml
|
||||
$(data_binding_stamp): PRIVATE_RES_OUT := $(data_binding_res_out)
|
||||
$(data_binding_stamp): PRIVATE_RES_IN := $(data_binding_res_in)
|
||||
$(data_binding_stamp): PRIVATE_ANNO_SRC_DIR := $(data_binding_intermediates)/anno-src
|
||||
|
||||
$(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \
|
||||
$(DATA_BINDING_COMPILER)
|
||||
@echo "Data-binding process: $@"
|
||||
@rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \
|
||||
mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \
|
||||
$(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR)
|
||||
$(hide) java -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \
|
||||
$(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN)
|
||||
$(hide) touch $@
|
||||
|
||||
# Make sure the data-binding process happens before javac and generation of R.java.
|
||||
$(R_file_stamp) $(full_classes_compiled_jar) : $(data_binding_stamp)
|
||||
# The dependency path when jack is enabled
|
||||
$(built_dex_intermediate) : $(data_binding_stamp)
|
||||
endif # LOCAL_DATA_BINDING
|
||||
|
||||
ifeq ($(need_compile_res),true)
|
||||
|
||||
# Since we don't know where the real R.java file is going to end up,
|
||||
|
|
|
@ -304,7 +304,7 @@ endif # TARGET JAVA_LIBRARIES
|
|||
|
||||
ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
|
||||
$(intermediates.COMMON)/classes.jack : PRIVATE_JILL_FLAGS:=$(LOCAL_JILL_FLAGS)
|
||||
$(intermediates.COMMON)/classes.jack : $(my_prebuilt_src_file) $(LOCAL_MODULE_MAKEFILE) \
|
||||
$(intermediates.COMMON)/classes.jack : $(my_src_jar) $(LOCAL_MODULE_MAKEFILE) \
|
||||
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(JILL_JAR) $(JACK_JAR) $(JACK_LAUNCHER_JAR)
|
||||
$(transform-jar-to-jack)
|
||||
|
||||
|
|
Loading…
Reference in New Issue