pdk_config.mk revision f8dc89b49ac64331f23c97d6aad3866dd3fb7344
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
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 $@)
49	$(hide) touch $@
50	$(call split-long-arguments,touch,$(_pdk_fusion_files))
51
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.
61$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
62	@mkdir -p $(dir $@)
63	$(hide) cp -fpPR $< $@
64
65ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
66
67endif
68
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
76