pdk_config.mk revision d8de82fbca4371ccefb41e02ac737e3a153901b3
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) the platform.zip exists in the default location 9# or 10# 2) PDK_FUSION_PLATFORM_ZIP is passed in from the environment 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# TODO: what's the best default location? 20_pdk_fusion_default_platform_zip := vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip 21ifneq (,$(wildcard $(_pdk_fusion_default_platform_zip))) 22$(info $(_pdk_fusion_default_platform_zip) found, do a PDK fusion build.) 23PDK_FUSION_PLATFORM_ZIP := $(_pdk_fusion_default_platform_zip) 24TARGET_BUILD_PDK := true 25endif 26 27ifneq (,$(filter pdk fusion, $(MAKECMDGOALS))) 28TARGET_BUILD_PDK := true 29ifneq (,$(filter fusion, $(MAKECMDGOALS))) 30ifndef PDK_FUSION_PLATFORM_ZIP 31 $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.) 32endif 33endif # fusion 34endif # pdk or fusion 35 36 37# additional items to add to platform.zip for platform-java build 38# For these dirs, add classes.jar and javalib.jar from the dir to platform.zip 39# all paths under out dir 40PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR := \ 41 target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates \ 42 target/common/obj/JAVA_LIBRARIES/core_intermediates \ 43 target/common/obj/JAVA_LIBRARIES/core-junit_intermediates \ 44 target/common/obj/JAVA_LIBRARIES/ext_intermediates \ 45 target/common/obj/JAVA_LIBRARIES/framework_intermediates \ 46 target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates 47# not java libraries 48PDK_PLATFORM_JAVA_ZIP_CONTENTS := \ 49 target/common/obj/APPS/framework-res_intermediates/package-export.apk \ 50 target/common/obj/APPS/framework-res_intermediates/src/R.stamp 51PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\ 52 $(lib_dir)/classes.jar $(lib_dir)/javalib.jar) 53 54 55ifdef PDK_FUSION_PLATFORM_ZIP 56TARGET_BUILD_PDK := true 57ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP))) 58 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).) 59endif 60 61_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion) 62_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp 63 64_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \ 65 '*[^/]' -x 'target/common/*' 2>/dev/null) 66_pdk_fusion_java_file_list := \ 67 $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null) 68_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\ 69 $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list)) 70ifneq ($(_pdk_fusion_java_file_list),) 71TARGET_BUILD_PDK_JAVA := true 72endif 73 74$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP) 75 @echo "Unzip $(dir $@) <- $<" 76 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) 77 $(hide) unzip -qo $< -d $(dir $@) 78 $(call split-long-arguments,-touch,$(_pdk_fusion_files)) 79 $(hide) touch $@ 80 81 82$(_pdk_fusion_files) : $(_pdk_fusion_stamp) 83 84 85# Implicit pattern rules to copy the fusion files to the system image directory. 86# Note that if there is already explicit rule in the build system to generate a file, 87# the pattern rule will be just ignored by make. 88# That's desired by us: we want only absent files from the platform zip package. 89# Copy with the last-modified time preserved, never follow symbolic links. 90$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp) 91 @mkdir -p $(dir $@) 92 $(hide) cp -fpPR $< $@ 93 94ifeq (true,$(TARGET_BUILD_PDK_JAVA)) 95 96define JAVA_dependency_template 97$(OUT_DIR)/$(strip $(1)): $(_pdk_fusion_intermediates)/$(strip $(1)) $(OUT_DIR)/$(strip $(2)) \ 98 $(_pdk_fusion_stamp) 99 @mkdir -p $$(dir $$@) 100 $(hide) cp -fpPR $$< $$@ 101endef 102 103# needs explicit dependency as package-export.apk is not explicitly pulled 104$(eval $(call JAVA_dependency_template,\ 105target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\ 106target/common/obj/APPS/framework-res_intermediates/package-export.apk)) 107 108# javalib.jar should pull classes.jar as classes.jar is not explicitly pulled. 109$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\ 110$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\ 111$(lib_dir)/classes.jar))) 112 113# implicit rules for all others 114$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp) 115 @mkdir -p $(dir $@) 116 $(hide) cp -fpPR $< $@ 117endif 118 119ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list)) 120 121endif # PDK_FUSION_PLATFORM_ZIP 122 123ifeq ($(TARGET_BUILD_PDK),true) 124 125ifeq ($(TARGET_BUILD_PDK_JAVA),) 126 127# SDK used for Java build under PDK 128PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS)) 129$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION)) 130 131else # PDK_JAVA 132 133$(info PDK Build uses the current platform API) 134 135endif # PDK_JAVA 136 137endif # BUILD_PDK 138