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