1214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Copyright (C) 2009 The Android Open Source Project 2214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# 3214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Licensed under the Apache License, Version 2.0 (the "License"); 4214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# you may not use this file except in compliance with the License. 5214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# You may obtain a copy of the License at 6214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# 7214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# http://www.apache.org/licenses/LICENSE-2.0 8214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# 9214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Unless required by applicable law or agreed to in writing, software 10214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# distributed under the License is distributed on an "AS IS" BASIS, 11214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# See the License for the specific language governing permissions and 13214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# limitations under the License. 14214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 15214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 16214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define 17214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# any of these rules. 18214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoaddon_name := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_NAME)) 19214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoifneq ($(addon_name),) 20214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 21eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onoratoaddon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME) 22eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onorato 23214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratointermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates 24eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onoratofull_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip 25eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onoratostaging := $(intermediates)/$(addon_dir_leaf) 26214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 27214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratosdk_addon_deps := 28214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratofiles_to_copy := 29214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 3030e0707531268343e11dfeb51f28ccdacd7f9875Raphaeldefine stub-addon-jar-file 3130e0707531268343e11dfeb51f28ccdacd7f9875Raphael$(subst .jar,_stub-addon.jar,$(1)) 3230e0707531268343e11dfeb51f28ccdacd7f9875Raphaelendef 3330e0707531268343e11dfeb51f28ccdacd7f9875Raphael 3430e0707531268343e11dfeb51f28ccdacd7f9875Raphaeldefine stub-addon-jar 3530e0707531268343e11dfeb51f28ccdacd7f9875Raphael$(call stub-addon-jar-file,$(1)): $(1) | mkstubs 3630e0707531268343e11dfeb51f28ccdacd7f9875Raphael $(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS)) 3730e0707531268343e11dfeb51f28ccdacd7f9875Raphael $(hide) java -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \ 3830e0707531268343e11dfeb51f28ccdacd7f9875Raphael "$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS) 3930e0707531268343e11dfeb51f28ccdacd7f9875Raphaelendef 4030e0707531268343e11dfeb51f28ccdacd7f9875Raphael 41214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Files that are built and then copied into the sdk-addon 42214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES)),) 43214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES), \ 44214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \ 4530e0707531268343e11dfeb51f28ccdacd7f9875Raphael $(eval $(call stub-addon-jar,$(_src))) \ 4630e0707531268343e11dfeb51f28ccdacd7f9875Raphael $(eval _src := $(call stub-addon-jar-file,$(_src))) \ 47214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \ 48214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval _dest := $(call word-colon,2,$(cf))) \ 49214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval files_to_copy += $(_src):$(_dest)) \ 50214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato ) 51214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoendif 52214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 53214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Files that are copied directly into the sdk-addon 54214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratofiles_to_copy += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES) 55214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 56214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# All SDK add-ons have these files 57214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratofiles_to_copy += \ 5818a130e98a654b99057d974f563a645dbb96010cBruce Beare $(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \ 5918a130e98a654b99057d974f563a645dbb96010cBruce Beare $(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \ 6018a130e98a654b99057d974f563a645dbb96010cBruce Beare $(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \ 61041fb639bfb979f4ab18d6dcaf63656639b2eec5David 'Digit' Turner $(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \ 6218a130e98a654b99057d974f563a645dbb96010cBruce Beare $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt 63214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 64214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# Generate rules to copy the requested files 65214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato$(foreach cf,$(files_to_copy), \ 66214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval _src := $(call word-colon,1,$(cf))) \ 67214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval _dest := $(call append-path,$(staging),$(call word-colon,2,$(cf)))) \ 68214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval $(call copy-one-file,$(_src),$(_dest))) \ 69214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(eval sdk_addon_deps += $(_dest)) \ 70214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato ) 71214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 72a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wang# We don't know about all of the docs files, so depend on the timestamps for 73a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wang# them, and record the directories, and the packaging rule will just copy the 74214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato# whole thing. 75a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wangdoc_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_DOC_MODULES)) 76a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wangsdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm))) 77a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wang$(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules)) 78214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 79214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato$(full_target): PRIVATE_STAGING_DIR := $(staging) 80214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 81214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato$(full_target): $(sdk_addon_deps) | $(ACP) 82214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato @echo Packaging SDK Addon: $@ 83b1df701ed849ab311344f0c1c94396d03e1835d4Marius Renn $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs 84a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wang $(hide) for d in $(PRIVATE_DOCS_DIRS); do \ 85b1df701ed849ab311344f0c1c94396d03e1835d4Marius Renn $(ACP) -r $$d $(PRIVATE_STAGING_DIR)/docs ;\ 86a032d3d07372423176e072dfcbcf60a53f8a7d57Ying Wang done 87214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato $(hide) mkdir -p $(dir $@) 88eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onorato $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F * ) 89214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 90214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato.PHONY: sdk_addon 91214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratosdk_addon: $(full_target) 92214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato 933e54830dc89794e17b3334190c0183faa40ac4d6Raphaelifneq ($(sdk_repo_goal),) 943e54830dc89794e17b3334190c0183faa40ac4d6Raphael# If we're building the sdk_repo, keep the name of the addon zip 953e54830dc89794e17b3334190c0183faa40ac4d6Raphael# around so that development/build/tools/sdk_repo.mk can dist it 963e54830dc89794e17b3334190c0183faa40ac4d6Raphael# at the appropriate location. 97c4d4731b4dd306b74b9e2245b4983b6b3c5b866eRaphaelADDON_SDK_ZIP := $(full_target) 983e54830dc89794e17b3334190c0183faa40ac4d6Raphaelelse 993e54830dc89794e17b3334190c0183faa40ac4d6Raphael# When not building an sdk_repo, just dist the addon zip file 1003e54830dc89794e17b3334190c0183faa40ac4d6Raphael# as-is. 101eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onorato$(call dist-for-goals, sdk_addon, $(full_target)) 1023e54830dc89794e17b3334190c0183faa40ac4d6Raphaelendif 103eb19b3e0d1189cc7833f185a067c9f80b5487707Joe Onorato 104214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoelse # addon_name 105214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoifneq ($(filter sdk_addon,$(MAKECMDGOALS)),) 106214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onorato$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one) 107214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoendif 108214a42bbb6e60f1231aa178c114a55dbe363c845Joe Onoratoendif # addon_name 109