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