blob: 41c3590acae30a38fc47980616a15b0066267d88 [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
Chad Jones07292322014-04-28 10:58:35 -070021# Most PDK project paths should be using vendor/pdk/TARGET_DEVICE
22# but some legacy ones (e.g. mini_armv7a_neon generic PDK) were setup
23# with vendor/pdk/TARGET_PRODUCT.
Dan Willemsen7c3e3f82015-09-29 16:30:21 -070024_pdk_fusion_default_platform_zip = $(strip \
25 $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
26 $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
27 $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
28 $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip))
keunyoung3b4856e2013-03-28 14:08:31 -070029ifneq (,$(_pdk_fusion_default_platform_zip))
30PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
Ying Wang82b836f2012-03-30 18:08:07 -070031TARGET_BUILD_PDK := true
keunyoung3b4856e2013-03-28 14:08:31 -070032$(info $(PDK_FUSION_PLATFORM_ZIP) found, do a PDK fusion build.)
33endif # _pdk_fusion_default_platform_zip
Keun young Park4da8e122012-08-02 12:51:59 -070034endif # !PDK_FUSION_PLATFORM_ZIP
Ying Wang82b836f2012-03-30 18:08:07 -070035
36ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
37TARGET_BUILD_PDK := true
38ifneq (,$(filter fusion, $(MAKECMDGOALS)))
39ifndef PDK_FUSION_PLATFORM_ZIP
40 $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.)
41endif
42endif # fusion
43endif # pdk or fusion
44
Colin Crossc451a372013-12-18 19:36:44 -080045PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR :=
46PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR := \
47 host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates
48PDK_PLATFORM_JAVA_ZIP_CONTENTS :=
49
Keun young Parkf4d14382012-06-18 12:46:46 -070050ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
Keun young Park816b9fd2012-05-16 10:32:41 -070051# additional items to add to platform.zip for platform-java build
52# For these dirs, add classes.jar and javalib.jar from the dir to platform.zip
53# all paths under out dir
Colin Crossc451a372013-12-18 19:36:44 -080054PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR += \
Nicholas Sauer1b2637e2015-03-27 09:26:27 -070055 target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates \
56 target/common/obj/JAVA_LIBRARIES/android-common_intermediates \
57 target/common/obj/JAVA_LIBRARIES/android-ex-camera2_intermediates \
58 target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates \
59 target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates \
60 target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates \
Piotr Jastrzebski89b94c82015-02-17 16:55:52 +000061 target/common/obj/JAVA_LIBRARIES/core-oj_intermediates \
Nicholas Sauer1b2637e2015-03-27 09:26:27 -070062 target/common/obj/JAVA_LIBRARIES/core-libart_intermediates \
63 target/common/obj/JAVA_LIBRARIES/core-junit_intermediates \
64 target/common/obj/JAVA_LIBRARIES/ext_intermediates \
65 target/common/obj/JAVA_LIBRARIES/framework_intermediates \
66 target/common/obj/JAVA_LIBRARIES/ims-common_intermediates \
67 target/common/obj/JAVA_LIBRARIES/okhttp_intermediates \
68 target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates \
69 target/common/obj/JAVA_LIBRARIES/voip-common_intermediates \
Colin Cross4b764992014-01-29 10:01:37 -080070
Colin Crossc451a372013-12-18 19:36:44 -080071# not java libraries
72PDK_PLATFORM_JAVA_ZIP_CONTENTS += \
73 target/common/obj/APPS/framework-res_intermediates/package-export.apk \
74 target/common/obj/APPS/framework-res_intermediates/src/R.stamp
75endif # platform-java or FUSION build
76
Colin Cross074d8382013-12-17 12:06:59 -080077PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR := \
78 $(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR) \
79 $(PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR)
Colin Crossc451a372013-12-18 19:36:44 -080080
Keun young Park816b9fd2012-05-16 10:32:41 -070081PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
Keun-young Parkc8d73492016-01-26 19:22:37 -080082 $(lib_dir)/classes.jack $(lib_dir)/classes.jar $(lib_dir)/classes.jar.toc \
83 $(lib_dir)/javalib.jar $(lib_dir)/classes*.dex \
84 $(lib_dir)/classes.dex.toc )
Keun young Park816b9fd2012-05-16 10:32:41 -070085
Keun young Parkefe02ce2012-06-06 17:19:29 -070086# check and override java support level
Keun young Parkf4d14382012-06-18 12:46:46 -070087ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070088ifneq ($(wildcard external/proguard),)
89TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
90else # no proguard
91TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
92endif
93# platform supprot is set after checking platform.zip
94endif # PDK
Keun young Park816b9fd2012-05-16 10:32:41 -070095
Ying Wang82b836f2012-03-30 18:08:07 -070096ifdef PDK_FUSION_PLATFORM_ZIP
97TARGET_BUILD_PDK := true
98ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
99 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
100endif
101
102_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
103_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
104
Keun young Park816b9fd2012-05-16 10:32:41 -0700105_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
106 '*[^/]' -x 'target/common/*' 2>/dev/null)
107_pdk_fusion_java_file_list := \
108 $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
109_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
110 $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
Keun young Parkefe02ce2012-06-06 17:19:29 -0700111
Keun young Park816b9fd2012-05-16 10:32:41 -0700112ifneq ($(_pdk_fusion_java_file_list),)
Keun young Parkefe02ce2012-06-06 17:19:29 -0700113# This represents whether java build can use platform API or not
114# This should not be used in Android.mk
115TARGET_BUILD_PDK_JAVA_PLATFORM := true
116ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
117TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
118endif
Keun young Park816b9fd2012-05-16 10:32:41 -0700119endif
120
Ying Wang82b836f2012-03-30 18:08:07 -0700121$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
122 @echo "Unzip $(dir $@) <- $<"
123 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
124 $(hide) unzip -qo $< -d $(dir $@)
Keun young Parkd8de82f2012-05-25 10:52:44 -0700125 $(call split-long-arguments,-touch,$(_pdk_fusion_files))
Keun young Park816b9fd2012-05-16 10:32:41 -0700126 $(hide) touch $@
Ying Wang82b836f2012-03-30 18:08:07 -0700127
Keun young Park816b9fd2012-05-16 10:32:41 -0700128
Ying Wang82b836f2012-03-30 18:08:07 -0700129$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
130
Keun young Park816b9fd2012-05-16 10:32:41 -0700131
Ying Wang82b836f2012-03-30 18:08:07 -0700132# Implicit pattern rules to copy the fusion files to the system image directory.
133# Note that if there is already explicit rule in the build system to generate a file,
134# the pattern rule will be just ignored by make.
135# That's desired by us: we want only absent files from the platform zip package.
136# Copy with the last-modified time preserved, never follow symbolic links.
Colin Cross2bea2e62012-04-23 18:49:04 -0700137$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
Ying Wang82b836f2012-03-30 18:08:07 -0700138 @mkdir -p $(dir $@)
Sungmin Choi79d51092013-02-04 00:54:03 +0900139 $(hide) rm -rf $@
Ying Wang82b836f2012-03-30 18:08:07 -0700140 $(hide) cp -fpPR $< $@
141
Colin Crossc451a372013-12-18 19:36:44 -0800142# implicit rules for host java files
143$(HOST_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/host/common/% $(_pdk_fusion_stamp)
144 @mkdir -p $(dir $@)
145 $(hide) cp -fpPR $< $@
146
Keun young Parkefe02ce2012-06-06 17:19:29 -0700147ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
Ying Wang82b836f2012-03-30 18:08:07 -0700148
keunyounga219bdc2013-07-25 18:20:09 -0700149PDK_FUSION_OUT_DIR := $(OUT_DIR)
Tom Cherry60767622012-06-14 17:33:38 -0700150ifeq (debug,$(TARGET_BUILD_TYPE))
151PDK_FUSION_OUT_DIR := $(DEBUG_OUT_DIR)
Tom Cherry60767622012-06-14 17:33:38 -0700152endif
keunyounga219bdc2013-07-25 18:20:09 -0700153
154define JAVA_dependency_template
Yohann Roussel00221d42016-01-29 13:06:11 +0100155$(call add-dependency,$(PDK_FUSION_OUT_DIR)/$(strip $(1)),\
156 $(foreach d,$(filter $(2),$(_pdk_fusion_java_file_list)),$(PDK_FUSION_OUT_DIR)/$(d)))
Keun young Park816b9fd2012-05-16 10:32:41 -0700157endef
158
159# needs explicit dependency as package-export.apk is not explicitly pulled
160$(eval $(call JAVA_dependency_template,\
161target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
162target/common/obj/APPS/framework-res_intermediates/package-export.apk))
163
164# javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
Colin Cross074d8382013-12-17 12:06:59 -0800165$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
Keun young Park816b9fd2012-05-16 10:32:41 -0700166$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
167$(lib_dir)/classes.jar)))
168
Keun-young Parkc8d73492016-01-26 19:22:37 -0800169# pull .jack and .dex files
170$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
171 $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.jar.toc,\
172 $(lib_dir)/classes.jar $(lib_dir)/classes.jack)))
173$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
174 $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.dex.toc,\
Yohann Roussel00221d42016-01-29 13:06:11 +0100175 $(lib_dir)/classes.jar $(lib_dir)/classes.jack $(lib_dir)/classes%.dex)))
Keun-young Parkc8d73492016-01-26 19:22:37 -0800176
Colin Cross074d8382013-12-17 12:06:59 -0800177# implicit rules for all other target files
Keun young Park816b9fd2012-05-16 10:32:41 -0700178$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
179 @mkdir -p $(dir $@)
180 $(hide) cp -fpPR $< $@
Ying Wang82b836f2012-03-30 18:08:07 -0700181endif
Keun young Parkebb351e2012-04-19 15:36:18 -0700182
Keun young Park816b9fd2012-05-16 10:32:41 -0700183ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
184
185endif # PDK_FUSION_PLATFORM_ZIP
186
Keun young Parkebb351e2012-04-19 15:36:18 -0700187ifeq ($(TARGET_BUILD_PDK),true)
Keun young Parkf4d14382012-06-18 12:46:46 -0700188$(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
Keun young Parkefe02ce2012-06-06 17:19:29 -0700189ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
Keun young Park816b9fd2012-05-16 10:32:41 -0700190
Keun young Parkebb351e2012-04-19 15:36:18 -0700191# SDK used for Java build under PDK
192PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
193$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
194
Keun young Park816b9fd2012-05-16 10:32:41 -0700195else # PDK_JAVA
196
197$(info PDK Build uses the current platform API)
198
199endif # PDK_JAVA
200
Keun young Parkebb351e2012-04-19 15:36:18 -0700201endif # BUILD_PDK
Keun young Park72226692012-07-31 17:13:20 -0700202
203ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
204# files under $(PRODUCT_OUT)/symbols to help debugging.
205# Source not included to PDK due to dependency issue, so provide symbols instead.
Ying Wang788c7782014-05-15 10:54:32 -0700206
Ying Wang00b83412014-05-15 16:13:15 -0700207# We may not be building all of them.
208# The platform.zip just silently ignores the nonexistent ones.
Keun young Park72226692012-07-31 17:13:20 -0700209PDK_SYMBOL_FILES_LIST := \
Ying Wang00b83412014-05-15 16:13:15 -0700210 system/bin/app_process32 \
211 system/bin/app_process64
Keun young Park72226692012-07-31 17:13:20 -0700212
213ifdef PDK_FUSION_PLATFORM_ZIP
214# symbols should be explicitly pulled for fusion build
Ying Wang00b83412014-05-15 16:13:15 -0700215$(foreach f,$(filter $(PDK_SYMBOL_FILES_LIST), $(_pdk_fusion_file_list)),\
Keun young Park72226692012-07-31 17:13:20 -0700216 $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
217endif # PLATFORM_ZIP
218endif # platform.zip build or PDK