blob: 71ddf7e04d5cb24b7b96c164dabe5f99f2bb3858 [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 Parkf4d14382012-06-18 12:46:46 -070036ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
Keun young Park816b9fd2012-05-16 10:32:41 -070037# 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)
Keun young Parkf4d14382012-06-18 12:46:46 -070053endif # platform-java or FUSION build
Keun young Park816b9fd2012-05-16 10:32:41 -070054
Keun young Parkefe02ce2012-06-06 17:19:29 -070055# check and override java support level
Keun young Parkf4d14382012-06-18 12:46:46 -070056ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070057ifneq ($(wildcard external/proguard),)
58TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
59else # no proguard
60TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
61endif
62# platform supprot is set after checking platform.zip
63endif # PDK
Keun young Park816b9fd2012-05-16 10:32:41 -070064
Ying Wang82b836f2012-03-30 18:08:07 -070065ifdef PDK_FUSION_PLATFORM_ZIP
66TARGET_BUILD_PDK := true
67ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
68 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
69endif
70
71_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
72_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
73
Keun young Park816b9fd2012-05-16 10:32:41 -070074_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
75 '*[^/]' -x 'target/common/*' 2>/dev/null)
76_pdk_fusion_java_file_list := \
77 $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
78_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
79 $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
Keun young Parkefe02ce2012-06-06 17:19:29 -070080
Keun young Park816b9fd2012-05-16 10:32:41 -070081ifneq ($(_pdk_fusion_java_file_list),)
Keun young Parkefe02ce2012-06-06 17:19:29 -070082# This represents whether java build can use platform API or not
83# This should not be used in Android.mk
84TARGET_BUILD_PDK_JAVA_PLATFORM := true
85ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
86TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
87endif
Keun young Park816b9fd2012-05-16 10:32:41 -070088endif
89
Ying Wang82b836f2012-03-30 18:08:07 -070090$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
91 @echo "Unzip $(dir $@) <- $<"
92 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
93 $(hide) unzip -qo $< -d $(dir $@)
Keun young Parkd8de82f2012-05-25 10:52:44 -070094 $(call split-long-arguments,-touch,$(_pdk_fusion_files))
Keun young Park816b9fd2012-05-16 10:32:41 -070095 $(hide) touch $@
Ying Wang82b836f2012-03-30 18:08:07 -070096
Keun young Park816b9fd2012-05-16 10:32:41 -070097
Ying Wang82b836f2012-03-30 18:08:07 -070098$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
99
Keun young Park816b9fd2012-05-16 10:32:41 -0700100
Ying Wang82b836f2012-03-30 18:08:07 -0700101# Implicit pattern rules to copy the fusion files to the system image directory.
102# Note that if there is already explicit rule in the build system to generate a file,
103# the pattern rule will be just ignored by make.
104# That's desired by us: we want only absent files from the platform zip package.
105# Copy with the last-modified time preserved, never follow symbolic links.
Colin Cross2bea2e62012-04-23 18:49:04 -0700106$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
Ying Wang82b836f2012-03-30 18:08:07 -0700107 @mkdir -p $(dir $@)
108 $(hide) cp -fpPR $< $@
109
Keun young Parkefe02ce2012-06-06 17:19:29 -0700110ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
Ying Wang82b836f2012-03-30 18:08:07 -0700111
Keun young Park816b9fd2012-05-16 10:32:41 -0700112define JAVA_dependency_template
113$(OUT_DIR)/$(strip $(1)): $(_pdk_fusion_intermediates)/$(strip $(1)) $(OUT_DIR)/$(strip $(2)) \
114 $(_pdk_fusion_stamp)
115 @mkdir -p $$(dir $$@)
116 $(hide) cp -fpPR $$< $$@
117endef
118
119# needs explicit dependency as package-export.apk is not explicitly pulled
120$(eval $(call JAVA_dependency_template,\
121target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
122target/common/obj/APPS/framework-res_intermediates/package-export.apk))
123
124# javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
125$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
126$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
127$(lib_dir)/classes.jar)))
128
129# implicit rules for all others
130$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
131 @mkdir -p $(dir $@)
132 $(hide) cp -fpPR $< $@
Ying Wang82b836f2012-03-30 18:08:07 -0700133endif
Keun young Parkebb351e2012-04-19 15:36:18 -0700134
Keun young Park816b9fd2012-05-16 10:32:41 -0700135ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
136
137endif # PDK_FUSION_PLATFORM_ZIP
138
Keun young Parkebb351e2012-04-19 15:36:18 -0700139ifeq ($(TARGET_BUILD_PDK),true)
Keun young Parkf4d14382012-06-18 12:46:46 -0700140$(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
Keun young Parkefe02ce2012-06-06 17:19:29 -0700141ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
Keun young Park816b9fd2012-05-16 10:32:41 -0700142
Keun young Parkebb351e2012-04-19 15:36:18 -0700143# SDK used for Java build under PDK
144PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
145$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
146
Keun young Park816b9fd2012-05-16 10:32:41 -0700147else # PDK_JAVA
148
149$(info PDK Build uses the current platform API)
150
151endif # PDK_JAVA
152
Keun young Parkebb351e2012-04-19 15:36:18 -0700153endif # BUILD_PDK