blob: 0949c38db1db7fad6181556430ae7a207547ac6f [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
36ifdef PDK_FUSION_PLATFORM_ZIP
37TARGET_BUILD_PDK := true
38ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
39 $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
40endif
41
42_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
43_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
44
45$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
46 @echo "Unzip $(dir $@) <- $<"
47 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
48 $(hide) unzip -qo $< -d $(dir $@)
Colin Crossf8dc89b2012-04-26 17:04:54 -070049 $(hide) touch $@
50 $(call split-long-arguments,touch,$(_pdk_fusion_files))
Ying Wang82b836f2012-03-30 18:08:07 -070051
52_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) '*[^/]' 2>/dev/null)
53_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/, $(_pdk_fusion_file_list))
54$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
55
56# Implicit pattern rules to copy the fusion files to the system image directory.
57# Note that if there is already explicit rule in the build system to generate a file,
58# the pattern rule will be just ignored by make.
59# That's desired by us: we want only absent files from the platform zip package.
60# Copy with the last-modified time preserved, never follow symbolic links.
Colin Cross2bea2e62012-04-23 18:49:04 -070061$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
Ying Wang82b836f2012-03-30 18:08:07 -070062 @mkdir -p $(dir $@)
63 $(hide) cp -fpPR $< $@
64
65ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
66
67endif
Keun young Parkebb351e2012-04-19 15:36:18 -070068
69ifeq ($(TARGET_BUILD_PDK),true)
70
71# SDK used for Java build under PDK
72PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
73$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
74
75endif # BUILD_PDK