Home | History | Annotate | Download | only in core
      1 # This file defines the rule to fuse the platform.zip into the current PDK build.
      2 PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR :=
      3 PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR := \
      4 	host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates
      5 PDK_PLATFORM_JAVA_ZIP_CONTENTS :=
      6 
      7 ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
      8 # additional items to add to platform.zip for platform-java build
      9 # For these dirs, add classes.jar and javalib.jar from the dir to platform.zip
     10 # all paths under out dir
     11 PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR += \
     12   target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates \
     13   target/common/obj/JAVA_LIBRARIES/android-common_intermediates \
     14   target/common/obj/JAVA_LIBRARIES/android-ex-camera2_intermediates \
     15   target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates \
     16   target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates \
     17   target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates \
     18   target/common/obj/JAVA_LIBRARIES/core-oj_intermediates \
     19   target/common/obj/JAVA_LIBRARIES/core-libart_intermediates \
     20   target/common/obj/JAVA_LIBRARIES/legacy-test_intermediates \
     21   target/common/obj/JAVA_LIBRARIES/ext_intermediates \
     22   target/common/obj/JAVA_LIBRARIES/framework_intermediates \
     23   target/common/obj/JAVA_LIBRARIES/ims-common_intermediates \
     24   target/common/obj/JAVA_LIBRARIES/okhttp_intermediates \
     25   target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates \
     26   target/common/obj/JAVA_LIBRARIES/voip-common_intermediates \
     27 
     28 # not java libraries
     29 PDK_PLATFORM_JAVA_ZIP_CONTENTS += \
     30 	target/common/obj/APPS/framework-res_intermediates/package-export.apk \
     31 	target/common/obj/APPS/framework-res_intermediates/src/R.stamp
     32 endif # platform-java or FUSION build
     33 
     34 PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR := \
     35 	$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR) \
     36 	$(PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR)
     37 
     38 PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
     39     $(lib_dir)/classes.jack $(lib_dir)/classes.jar $(lib_dir)/classes.jar.toc \
     40     $(lib_dir)/javalib.jar  $(lib_dir)/classes*.dex \
     41     $(lib_dir)/classes.dex.toc )
     42 
     43 # check and override java support level
     44 ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
     45 ifneq ($(wildcard external/proguard),)
     46 TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
     47 else # no proguard
     48 TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
     49 endif
     50 # platform supprot is set after checking platform.zip
     51 endif # PDK
     52 
     53 ifdef PDK_FUSION_PLATFORM_ZIP
     54 _pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
     55 _pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
     56 
     57 _pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
     58     '*[^/]' -x 'target/common/*' 2>/dev/null)
     59 _pdk_fusion_java_file_list := \
     60 	$(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
     61 _pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
     62     $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
     63 
     64 ifneq ($(_pdk_fusion_java_file_list),)
     65 # This represents whether java build can use platform API or not
     66 # This should not be used in Android.mk
     67 TARGET_BUILD_PDK_JAVA_PLATFORM := true
     68 ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
     69 TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
     70 endif
     71 endif
     72 
     73 $(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
     74 	@echo "Unzip $(dir $@) <- $<"
     75 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
     76 	$(hide) unzip -qo $< -d $(dir $@)
     77 	$(call split-long-arguments,-touch,$(_pdk_fusion_files))
     78 	$(hide) touch $@
     79 
     80 
     81 $(_pdk_fusion_files) : $(_pdk_fusion_stamp)
     82 
     83 
     84 # Implicit pattern rules to copy the fusion files to the system image directory.
     85 # Note that if there is already explicit rule in the build system to generate a file,
     86 # the pattern rule will be just ignored by make.
     87 # That's desired by us: we want only absent files from the platform zip package.
     88 # Copy with the last-modified time preserved, never follow symbolic links.
     89 $(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
     90 	@mkdir -p $(dir $@)
     91 	$(hide) rm -rf $@
     92 	$(hide) cp -fpPR $< $@
     93 
     94 # implicit rules for host java files
     95 $(HOST_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/host/common/% $(_pdk_fusion_stamp)
     96 	@mkdir -p $(dir $@)
     97 	$(hide) cp -fpPR $< $@
     98 
     99 ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
    100 
    101 PDK_FUSION_OUT_DIR := $(OUT_DIR)
    102 ifeq (debug,$(TARGET_BUILD_TYPE))
    103 PDK_FUSION_OUT_DIR := $(DEBUG_OUT_DIR)
    104 endif
    105 
    106 define JAVA_dependency_template
    107 $(call add-dependency,$(PDK_FUSION_OUT_DIR)/$(strip $(1)),\
    108   $(foreach d,$(filter $(2),$(_pdk_fusion_java_file_list)),$(PDK_FUSION_OUT_DIR)/$(d)))
    109 endef
    110 
    111 # needs explicit dependency as package-export.apk is not explicitly pulled
    112 $(eval $(call JAVA_dependency_template,\
    113 target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
    114 target/common/obj/APPS/framework-res_intermediates/package-export.apk))
    115 
    116 # javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
    117 $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
    118 $(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
    119 $(lib_dir)/classes.jar)))
    120 
    121 # pull .jack and .dex files
    122 $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
    123   $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.jar.toc,\
    124     $(lib_dir)/classes.jar $(lib_dir)/classes.jack)))
    125 $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
    126   $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.dex.toc,\
    127     $(lib_dir)/classes.jar $(lib_dir)/classes.jack $(lib_dir)/classes%.dex)))
    128 
    129 # implicit rules for all other target files
    130 $(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
    131 	@mkdir -p $(dir $@)
    132 	$(hide) cp -fpPR $< $@
    133 endif
    134 
    135 ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
    136 
    137 endif # PDK_FUSION_PLATFORM_ZIP
    138 
    139 ifeq ($(TARGET_BUILD_PDK),true)
    140 $(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
    141 ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
    142 
    143 # SDK used for Java build under PDK
    144 PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
    145 $(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
    146 
    147 else # PDK_JAVA
    148 
    149 $(info PDK Build uses the current platform API)
    150 
    151 endif # PDK_JAVA
    152 
    153 endif # BUILD_PDK
    154 
    155 ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
    156 # files under $(PRODUCT_OUT)/symbols to help debugging.
    157 # Source not included to PDK due to dependency issue, so provide symbols instead.
    158 
    159 # We may not be building all of them.
    160 # The platform.zip just silently ignores the nonexistent ones.
    161 PDK_SYMBOL_FILES_LIST := \
    162     system/bin/app_process32 \
    163     system/bin/app_process64
    164 
    165 ifdef PDK_FUSION_PLATFORM_ZIP
    166 # symbols should be explicitly pulled for fusion build
    167 $(foreach f,$(filter $(PDK_SYMBOL_FILES_LIST), $(_pdk_fusion_file_list)),\
    168   $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
    169 endif # PLATFORM_ZIP
    170 endif # platform.zip build or PDK
    171