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