1 # This file defines the rule to fuse the platform.zip into the current PDK build.
4 pdk fusion: $(DEFAULT_GOAL)
8 # 1) PDK_FUSION_PLATFORM_ZIP is passed in from the environment
10 # 2) the platform.zip exists in the default location
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
17 # 2) TARGET_BUILD_PDK is passed in from the environment
19 # if PDK_FUSION_PLATFORM_ZIP is specified, do not override.
20 ifndef PDK_FUSION_PLATFORM_ZIP
21 _pdk_fusion_default_platform_zip = $(wildcard \
22 vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip \
23 vendor/pdk/$(TARGET_DEVICE)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip)
24 ifneq (,$(_pdk_fusion_default_platform_zip))
25 PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
26 TARGET_BUILD_PDK := true
27 $(info $(PDK_FUSION_PLATFORM_ZIP) found, do a PDK fusion build.)
28 endif # _pdk_fusion_default_platform_zip
29 endif # !PDK_FUSION_PLATFORM_ZIP
31 ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
32 TARGET_BUILD_PDK := true
33 ifneq (,$(filter fusion, $(MAKECMDGOALS)))
34 ifndef PDK_FUSION_PLATFORM_ZIP
35 $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.)
40 ifneq (,$(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
44 PDK_PLATFORM_JAVA_ZIP_JAVA_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
57 PDK_PLATFORM_JAVA_ZIP_CONTENTS := \
58 target/common/obj/APPS/framework-res_intermediates/package-export.apk \
59 target/common/obj/APPS/framework-res_intermediates/src/R.stamp
60 PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
61 $(lib_dir)/classes.jar $(lib_dir)/javalib.jar)
62 endif # platform-java or FUSION build
64 # check and override java support level
65 ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
66 ifneq ($(wildcard external/proguard),)
67 TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
69 TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
71 # platform supprot is set after checking platform.zip
74 ifdef PDK_FUSION_PLATFORM_ZIP
75 TARGET_BUILD_PDK := true
76 ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
77 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
80 _pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
81 _pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
83 _pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
84 '*[^/]' -x 'target/common/*' 2>/dev/null)
85 _pdk_fusion_java_file_list := \
86 $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
87 _pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
88 $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
90 ifneq ($(_pdk_fusion_java_file_list),)
91 # This represents whether java build can use platform API or not
92 # This should not be used in Android.mk
93 TARGET_BUILD_PDK_JAVA_PLATFORM := true
94 ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
95 TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
99 $(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
100 @echo "Unzip $(dir $@) <- $<"
101 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
102 $(hide) unzip -qo $< -d $(dir $@)
103 $(call split-long-arguments,-touch,$(_pdk_fusion_files))
107 $(_pdk_fusion_files) : $(_pdk_fusion_stamp)
110 # Implicit pattern rules to copy the fusion files to the system image directory.
111 # Note that if there is already explicit rule in the build system to generate a file,
112 # the pattern rule will be just ignored by make.
113 # That's desired by us: we want only absent files from the platform zip package.
114 # Copy with the last-modified time preserved, never follow symbolic links.
115 $(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
118 $(hide) cp -fpPR $< $@
120 ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
122 PDK_FUSION_OUT_DIR := $(OUT_DIR)
123 ifeq (debug,$(TARGET_BUILD_TYPE))
124 PDK_FUSION_OUT_DIR := $(DEBUG_OUT_DIR)
127 define JAVA_dependency_template
128 $(PDK_FUSION_OUT_DIR)/$(strip $(1)): $(_pdk_fusion_intermediates)/$(strip $(1)) \
129 $(PDK_FUSION_OUT_DIR)/$(strip $(2)) $(_pdk_fusion_stamp)
130 @mkdir -p $$(dir $$@)
131 $(hide) cp -fpPR $$< $$@
134 # needs explicit dependency as package-export.apk is not explicitly pulled
135 $(eval $(call JAVA_dependency_template,\
136 target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
137 target/common/obj/APPS/framework-res_intermediates/package-export.apk))
139 # javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
140 $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
141 $(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
142 $(lib_dir)/classes.jar)))
144 # implicit rules for all others
145 $(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
147 $(hide) cp -fpPR $< $@
150 ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
152 endif # PDK_FUSION_PLATFORM_ZIP
154 ifeq ($(TARGET_BUILD_PDK),true)
155 $(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
156 ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
158 # SDK used for Java build under PDK
159 PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
160 $(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
164 $(info PDK Build uses the current platform API)
170 ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
171 # files under $(PRODUCT_OUT)/symbols to help debugging.
172 # Source not included to PDK due to dependency issue, so provide symbols instead.
173 PDK_SYMBOL_FILES_LIST := \
174 system/bin/app_process
176 ifdef PDK_FUSION_PLATFORM_ZIP
177 # symbols should be explicitly pulled for fusion build
178 $(foreach f,$(PDK_SYMBOL_FILES_LIST),\
179 $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
181 endif # platform.zip build or PDK