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