blob: 9df2ce249fedde6f171688d6075aa0ad95a868a0 [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:
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?
Colin Cross21adee02012-04-19 00:50:00 -070020_pdk_fusion_default_platform_zip := vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip
Ying Wang82b836f2012-03-30 18:08:07 -070021ifneq (,$(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
Keun young Park816b9fd2012-05-16 10:32:41 -070036
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
Keun young Parkefe02ce2012-06-06 17:19:29 -070054# 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
Keun young Park816b9fd2012-05-16 10:32:41 -070063
Ying Wang82b836f2012-03-30 18:08:07 -070064ifdef 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
Keun young Park816b9fd2012-05-16 10:32:41 -070073_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))
Keun young Parkefe02ce2012-06-06 17:19:29 -070079
Keun young Park816b9fd2012-05-16 10:32:41 -070080ifneq ($(_pdk_fusion_java_file_list),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070081# 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
Keun young Park816b9fd2012-05-16 10:32:41 -070087endif
88
Ying Wang82b836f2012-03-30 18:08:07 -070089$(_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 $@)
Keun young Parkd8de82f2012-05-25 10:52:44 -070093 $(call split-long-arguments,-touch,$(_pdk_fusion_files))
Keun young Park816b9fd2012-05-16 10:32:41 -070094 $(hide) touch $@
Ying Wang82b836f2012-03-30 18:08:07 -070095
Keun young Park816b9fd2012-05-16 10:32:41 -070096
Ying Wang82b836f2012-03-30 18:08:07 -070097$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
98
Keun young Park816b9fd2012-05-16 10:32:41 -070099
Ying Wang82b836f2012-03-30 18:08:07 -0700100# 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.
Colin Cross2bea2e62012-04-23 18:49:04 -0700105$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
Ying Wang82b836f2012-03-30 18:08:07 -0700106 @mkdir -p $(dir $@)
107 $(hide) cp -fpPR $< $@
108
Keun young Parkefe02ce2012-06-06 17:19:29 -0700109ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
Ying Wang82b836f2012-03-30 18:08:07 -0700110
Keun young Park816b9fd2012-05-16 10:32:41 -0700111define 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 $< $@
Ying Wang82b836f2012-03-30 18:08:07 -0700132endif
Keun young Parkebb351e2012-04-19 15:36:18 -0700133
Keun young Park816b9fd2012-05-16 10:32:41 -0700134ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
135
136endif # PDK_FUSION_PLATFORM_ZIP
137
Keun young Parkebb351e2012-04-19 15:36:18 -0700138ifeq ($(TARGET_BUILD_PDK),true)
139
Keun young Parkefe02ce2012-06-06 17:19:29 -0700140ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
Keun young Park816b9fd2012-05-16 10:32:41 -0700141
Keun young Parkebb351e2012-04-19 15:36:18 -0700142# 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
Keun young Park816b9fd2012-05-16 10:32:41 -0700146else # PDK_JAVA
147
148$(info PDK Build uses the current platform API)
149
150endif # PDK_JAVA
151
Keun young Parkebb351e2012-04-19 15:36:18 -0700152endif # BUILD_PDK