pdk_config.mk revision 052a00f64e82b524fcb4320897b46dc941670a22
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# 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.
24_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))
29ifneq (,$(_pdk_fusion_default_platform_zip))
30PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
31TARGET_BUILD_PDK := true
32$(info $(PDK_FUSION_PLATFORM_ZIP) found, do a PDK fusion build.)
33endif # _pdk_fusion_default_platform_zip
34endif # !PDK_FUSION_PLATFORM_ZIP
35
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
45PDK_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
50ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
51# 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
54PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR += \
55  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 \
61  target/common/obj/JAVA_LIBRARIES/core-oj_intermediates \
62  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 \
70
71# 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
77PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR := \
78	$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR) \
79	$(PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR)
80
81PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
82    $(lib_dir)/classes.jack $(lib_dir)/classes.jar $(lib_dir)/javalib.jar)
83
84# check and override java support level
85ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
86ifneq ($(wildcard external/proguard),)
87TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
88else # no proguard
89TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
90endif
91# platform supprot is set after checking platform.zip
92endif # PDK
93
94ifdef PDK_FUSION_PLATFORM_ZIP
95TARGET_BUILD_PDK := true
96ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
97  $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
98endif
99
100_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
101_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
102
103_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
104    '*[^/]' -x 'target/common/*' 2>/dev/null)
105_pdk_fusion_java_file_list := \
106	$(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
107_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
108    $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
109
110ifneq ($(_pdk_fusion_java_file_list),)
111# This represents whether java build can use platform API or not
112# This should not be used in Android.mk
113TARGET_BUILD_PDK_JAVA_PLATFORM := true
114ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
115TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
116endif
117endif
118
119$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
120	@echo "Unzip $(dir $@) <- $<"
121	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
122	$(hide) unzip -qo $< -d $(dir $@)
123	$(call split-long-arguments,-touch,$(_pdk_fusion_files))
124	$(hide) touch $@
125
126
127$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
128
129
130# Implicit pattern rules to copy the fusion files to the system image directory.
131# Note that if there is already explicit rule in the build system to generate a file,
132# the pattern rule will be just ignored by make.
133# That's desired by us: we want only absent files from the platform zip package.
134# Copy with the last-modified time preserved, never follow symbolic links.
135$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
136	@mkdir -p $(dir $@)
137	$(hide) rm -rf $@
138	$(hide) cp -fpPR $< $@
139
140# implicit rules for host java files
141$(HOST_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/host/common/% $(_pdk_fusion_stamp)
142	@mkdir -p $(dir $@)
143	$(hide) cp -fpPR $< $@
144
145ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
146
147PDK_FUSION_OUT_DIR := $(OUT_DIR)
148ifeq (debug,$(TARGET_BUILD_TYPE))
149PDK_FUSION_OUT_DIR := $(DEBUG_OUT_DIR)
150endif
151
152define JAVA_dependency_template
153$(PDK_FUSION_OUT_DIR)/$(strip $(1)): $(_pdk_fusion_intermediates)/$(strip $(1)) \
154  $(PDK_FUSION_OUT_DIR)/$(strip $(2)) $(_pdk_fusion_stamp)
155	@mkdir -p $$(dir $$@)
156	$(hide) cp -fpPR $$< $$@
157endef
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.
165$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
166$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
167$(lib_dir)/classes.jar)))
168
169# implicit rules for all other target files
170$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
171	@mkdir -p $(dir $@)
172	$(hide) cp -fpPR $< $@
173endif
174
175ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
176
177endif # PDK_FUSION_PLATFORM_ZIP
178
179ifeq ($(TARGET_BUILD_PDK),true)
180$(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
181ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
182
183# SDK used for Java build under PDK
184PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
185$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
186
187else # PDK_JAVA
188
189$(info PDK Build uses the current platform API)
190
191endif # PDK_JAVA
192
193endif # BUILD_PDK
194
195ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
196# files under $(PRODUCT_OUT)/symbols to help debugging.
197# Source not included to PDK due to dependency issue, so provide symbols instead.
198
199# We may not be building all of them.
200# The platform.zip just silently ignores the nonexistent ones.
201PDK_SYMBOL_FILES_LIST := \
202    system/bin/app_process32 \
203    system/bin/app_process64
204
205ifdef PDK_FUSION_PLATFORM_ZIP
206# symbols should be explicitly pulled for fusion build
207$(foreach f,$(filter $(PDK_SYMBOL_FILES_LIST), $(_pdk_fusion_file_list)),\
208  $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
209endif # PLATFORM_ZIP
210endif # platform.zip build or PDK
211