blob: a864781942c4d5f02620a1a305ca75c91b892459 [file] [log] [blame]
Joe Onorato214a42b2009-04-09 20:36:06 -07001# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16# If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define
17# any of these rules.
18addon_name := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_NAME))
19ifneq ($(addon_name),)
20
Joe Onoratoeb19b3e2009-04-13 16:32:16 -070021addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME)
22
Joe Onorato214a42b2009-04-09 20:36:06 -070023intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates
Joe Onoratoeb19b3e2009-04-13 16:32:16 -070024full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip
25staging := $(intermediates)/$(addon_dir_leaf)
Joe Onorato214a42b2009-04-09 20:36:06 -070026
27sdk_addon_deps :=
28files_to_copy :=
29
Raphael30e07072011-02-03 22:59:27 -080030define stub-addon-jar-file
31$(subst .jar,_stub-addon.jar,$(1))
32endef
33
34define stub-addon-jar
35$(call stub-addon-jar-file,$(1)): $(1) | mkstubs
36 $(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS))
37 $(hide) java -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \
38 "$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS)
39endef
40
Joe Onorato214a42b2009-04-09 20:36:06 -070041# Files that are built and then copied into the sdk-addon
42ifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES)),)
43$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES), \
44 $(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \
Raphael30e07072011-02-03 22:59:27 -080045 $(eval $(call stub-addon-jar,$(_src))) \
46 $(eval _src := $(call stub-addon-jar-file,$(_src))) \
Joe Onorato214a42b2009-04-09 20:36:06 -070047 $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \
48 $(eval _dest := $(call word-colon,2,$(cf))) \
49 $(eval files_to_copy += $(_src):$(_dest)) \
50 )
51endif
52
53# Files that are copied directly into the sdk-addon
54files_to_copy += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES)
55
56# All SDK add-ons have these files
57files_to_copy += \
Bruce Beare18a130e2011-02-18 15:06:20 -080058 $(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
59 $(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \
60 $(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \
David 'Digit' Turner041fb632011-08-31 00:43:07 +020061 $(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
Bruce Beare18a130e2011-02-18 15:06:20 -080062 $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt
Joe Onorato214a42b2009-04-09 20:36:06 -070063
64# Generate rules to copy the requested files
65$(foreach cf,$(files_to_copy), \
66 $(eval _src := $(call word-colon,1,$(cf))) \
67 $(eval _dest := $(call append-path,$(staging),$(call word-colon,2,$(cf)))) \
68 $(eval $(call copy-one-file,$(_src),$(_dest))) \
69 $(eval sdk_addon_deps += $(_dest)) \
70 )
71
Ying Wanga032d3d2011-11-11 10:52:12 -080072# We don't know about all of the docs files, so depend on the timestamps for
73# them, and record the directories, and the packaging rule will just copy the
Joe Onorato214a42b2009-04-09 20:36:06 -070074# whole thing.
Ying Wanga032d3d2011-11-11 10:52:12 -080075doc_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_DOC_MODULES))
76sdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm)))
77$(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules))
Joe Onorato214a42b2009-04-09 20:36:06 -070078
79$(full_target): PRIVATE_STAGING_DIR := $(staging)
80
81$(full_target): $(sdk_addon_deps) | $(ACP)
82 @echo Packaging SDK Addon: $@
83 $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs/reference
Ying Wanga032d3d2011-11-11 10:52:12 -080084 $(hide) for d in $(PRIVATE_DOCS_DIRS); do \
85 $(ACP) -r $$d/* $(PRIVATE_STAGING_DIR)/docs/reference ;\
86 done
Joe Onorato214a42b2009-04-09 20:36:06 -070087 $(hide) mkdir -p $(dir $@)
Joe Onoratoeb19b3e2009-04-13 16:32:16 -070088 $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F * )
Joe Onorato214a42b2009-04-09 20:36:06 -070089
90.PHONY: sdk_addon
91sdk_addon: $(full_target)
92
Raphael3e548302011-02-23 16:45:57 -080093ifneq ($(sdk_repo_goal),)
94# If we're building the sdk_repo, keep the name of the addon zip
95# around so that development/build/tools/sdk_repo.mk can dist it
96# at the appropriate location.
Raphaelc4d47312011-02-15 16:09:36 -080097ADDON_SDK_ZIP := $(full_target)
Raphael3e548302011-02-23 16:45:57 -080098else
99# When not building an sdk_repo, just dist the addon zip file
100# as-is.
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700101$(call dist-for-goals, sdk_addon, $(full_target))
Raphael3e548302011-02-23 16:45:57 -0800102endif
Joe Onoratoeb19b3e2009-04-13 16:32:16 -0700103
Joe Onorato214a42b2009-04-09 20:36:06 -0700104else # addon_name
105ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
106$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
107endif
108endif # addon_name