blob: 41a82d4f4574782ddc07b6b6065b13ac3f78f4df [file] [log] [blame]
Ying Wang82b836f2012-03-30 18:08:07 -07001# 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:
Keun young Park4da8e122012-08-02 12:51:59 -07008# 1) PDK_FUSION_PLATFORM_ZIP is passed in from the environment
Ying Wang82b836f2012-03-30 18:08:07 -07009# or
Keun young Park4da8e122012-08-02 12:51:59 -070010# 2) the platform.zip exists in the default location
Ying Wang82b836f2012-03-30 18:08:07 -070011# 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
Keun young Park4da8e122012-08-02 12:51:59 -070019# if PDK_FUSION_PLATFORM_ZIP is specified, do not override.
20ifndef PDK_FUSION_PLATFORM_ZIP
keunyoung3b4856e2013-03-28 14:08:31 -070021_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))
Ying Wang82b836f2012-03-30 18:08:07 -070026TARGET_BUILD_PDK := true
keunyoung3b4856e2013-03-28 14:08:31 -070027$(info $(PDK_FUSION_PLATFORM_ZIP) found, do a PDK fusion build.)
28endif # _pdk_fusion_default_platform_zip
Keun young Park4da8e122012-08-02 12:51:59 -070029endif # !PDK_FUSION_PLATFORM_ZIP
Ying Wang82b836f2012-03-30 18:08:07 -070030
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
Keun young Parkf4d14382012-06-18 12:46:46 -070040ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
Keun young Park816b9fd2012-05-16 10:32:41 -070041# 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
44PDK_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 \
Colin Cross6fe6c3c2012-07-18 16:00:48 -070050 target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates \
51 target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates \
Wink Saville554a0ad2013-01-28 15:30:58 -080052 target/common/obj/JAVA_LIBRARIES/voip-common_intermediates \
Colin Cross6fe6c3c2012-07-18 16:00:48 -070053 target/common/obj/JAVA_LIBRARIES/mms-common_intermediates
Keun young Park816b9fd2012-05-16 10:32:41 -070054# not java libraries
55PDK_PLATFORM_JAVA_ZIP_CONTENTS := \
56 target/common/obj/APPS/framework-res_intermediates/package-export.apk \
57 target/common/obj/APPS/framework-res_intermediates/src/R.stamp
58PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
59 $(lib_dir)/classes.jar $(lib_dir)/javalib.jar)
Keun young Parkf4d14382012-06-18 12:46:46 -070060endif # platform-java or FUSION build
Keun young Park816b9fd2012-05-16 10:32:41 -070061
Keun young Parkefe02ce2012-06-06 17:19:29 -070062# check and override java support level
Keun young Parkf4d14382012-06-18 12:46:46 -070063ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070064ifneq ($(wildcard external/proguard),)
65TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
66else # no proguard
67TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
68endif
69# platform supprot is set after checking platform.zip
70endif # PDK
Keun young Park816b9fd2012-05-16 10:32:41 -070071
Ying Wang82b836f2012-03-30 18:08:07 -070072ifdef PDK_FUSION_PLATFORM_ZIP
73TARGET_BUILD_PDK := true
74ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
75 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
76endif
77
78_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
79_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
80
Keun young Park816b9fd2012-05-16 10:32:41 -070081_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
82 '*[^/]' -x 'target/common/*' 2>/dev/null)
83_pdk_fusion_java_file_list := \
84 $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
85_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
86 $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
Keun young Parkefe02ce2012-06-06 17:19:29 -070087
Keun young Park816b9fd2012-05-16 10:32:41 -070088ifneq ($(_pdk_fusion_java_file_list),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070089# This represents whether java build can use platform API or not
90# This should not be used in Android.mk
91TARGET_BUILD_PDK_JAVA_PLATFORM := true
92ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
93TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
94endif
Keun young Park816b9fd2012-05-16 10:32:41 -070095endif
96
Ying Wang82b836f2012-03-30 18:08:07 -070097$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
98 @echo "Unzip $(dir $@) <- $<"
99 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
100 $(hide) unzip -qo $< -d $(dir $@)
Keun young Parkd8de82f2012-05-25 10:52:44 -0700101 $(call split-long-arguments,-touch,$(_pdk_fusion_files))
Keun young Park816b9fd2012-05-16 10:32:41 -0700102 $(hide) touch $@
Ying Wang82b836f2012-03-30 18:08:07 -0700103
Keun young Park816b9fd2012-05-16 10:32:41 -0700104
Ying Wang82b836f2012-03-30 18:08:07 -0700105$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
106
Keun young Park816b9fd2012-05-16 10:32:41 -0700107
Ying Wang82b836f2012-03-30 18:08:07 -0700108# Implicit pattern rules to copy the fusion files to the system image directory.
109# Note that if there is already explicit rule in the build system to generate a file,
110# the pattern rule will be just ignored by make.
111# That's desired by us: we want only absent files from the platform zip package.
112# Copy with the last-modified time preserved, never follow symbolic links.
Colin Cross2bea2e62012-04-23 18:49:04 -0700113$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
Ying Wang82b836f2012-03-30 18:08:07 -0700114 @mkdir -p $(dir $@)
Sungmin Choi79d51092013-02-04 00:54:03 +0900115 $(hide) rm -rf $@
Ying Wang82b836f2012-03-30 18:08:07 -0700116 $(hide) cp -fpPR $< $@
117
Keun young Parkefe02ce2012-06-06 17:19:29 -0700118ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
Ying Wang82b836f2012-03-30 18:08:07 -0700119
Keun young Park816b9fd2012-05-16 10:32:41 -0700120define JAVA_dependency_template
121$(OUT_DIR)/$(strip $(1)): $(_pdk_fusion_intermediates)/$(strip $(1)) $(OUT_DIR)/$(strip $(2)) \
122 $(_pdk_fusion_stamp)
123 @mkdir -p $$(dir $$@)
124 $(hide) cp -fpPR $$< $$@
125endef
126
127# needs explicit dependency as package-export.apk is not explicitly pulled
128$(eval $(call JAVA_dependency_template,\
129target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
130target/common/obj/APPS/framework-res_intermediates/package-export.apk))
131
132# javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
133$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
134$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
135$(lib_dir)/classes.jar)))
136
137# implicit rules for all others
138$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
139 @mkdir -p $(dir $@)
140 $(hide) cp -fpPR $< $@
Ying Wang82b836f2012-03-30 18:08:07 -0700141endif
Keun young Parkebb351e2012-04-19 15:36:18 -0700142
Keun young Park816b9fd2012-05-16 10:32:41 -0700143ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
144
145endif # PDK_FUSION_PLATFORM_ZIP
146
Keun young Parkebb351e2012-04-19 15:36:18 -0700147ifeq ($(TARGET_BUILD_PDK),true)
Keun young Parkf4d14382012-06-18 12:46:46 -0700148$(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
Keun young Parkefe02ce2012-06-06 17:19:29 -0700149ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
Keun young Park816b9fd2012-05-16 10:32:41 -0700150
Keun young Parkebb351e2012-04-19 15:36:18 -0700151# SDK used for Java build under PDK
152PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
153$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
154
Keun young Park816b9fd2012-05-16 10:32:41 -0700155else # PDK_JAVA
156
157$(info PDK Build uses the current platform API)
158
159endif # PDK_JAVA
160
Keun young Parkebb351e2012-04-19 15:36:18 -0700161endif # BUILD_PDK
Keun young Park72226692012-07-31 17:13:20 -0700162
163ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
164# files under $(PRODUCT_OUT)/symbols to help debugging.
165# Source not included to PDK due to dependency issue, so provide symbols instead.
166PDK_SYMBOL_FILES_LIST := \
167 system/bin/app_process
168
169ifdef PDK_FUSION_PLATFORM_ZIP
170# symbols should be explicitly pulled for fusion build
171$(foreach f,$(PDK_SYMBOL_FILES_LIST),\
172 $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
173endif # PLATFORM_ZIP
174endif # platform.zip build or PDK