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