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