sdk-addon.mk revision 15ca0bd5d0a028fd8e42f72a45f17d8e1ee67485
1# 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 21addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME) 22 23intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates 24full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip 25staging := $(intermediates)/$(addon_dir_leaf) 26 27sdk_addon_deps := 28files_to_copy := 29 30# Files that are built and then copied into the sdk-addon 31ifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES)),) 32$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES), \ 33 $(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \ 34 $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \ 35 $(eval _dest := $(call word-colon,2,$(cf))) \ 36 $(eval files_to_copy += $(_src):$(_dest)) \ 37 ) 38endif 39 40# Files that are copied directly into the sdk-addon 41files_to_copy += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES) 42 43# All SDK add-ons have these files 44files_to_copy += \ 45 $(BUILT_SYSTEMIMAGE):images/system.img \ 46 $(BUILT_USERDATAIMAGE_TARGET):images/userdata.img \ 47 $(BUILT_RAMDISK_TARGET):images/ramdisk.img \ 48 $(target_notice_file_txt):images/NOTICE.txt 49 50# Generate rules to copy the requested files 51$(foreach cf,$(files_to_copy), \ 52 $(eval _src := $(call word-colon,1,$(cf))) \ 53 $(eval _dest := $(call append-path,$(staging),$(call word-colon,2,$(cf)))) \ 54 $(eval $(call copy-one-file,$(_src),$(_dest))) \ 55 $(eval sdk_addon_deps += $(_dest)) \ 56 ) 57 58# We don't know about all of the docs files, so depend on the timestamp for 59# that, and record the directory, and the packaging rule will just copy the 60# whole thing. 61doc_module := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_DOC_MODULE)) 62ifneq ($(doc_module),) 63 doc_timestamp := $(call doc-timestamp-for, $(doc_module)) 64 sdk_addon_deps += $(doc_timestamp) 65 $(full_target): PRIVATE_DOCS_DIR := $(OUT_DOCS)/$(doc_module) 66else 67 $(full_target): PRIVATE_DOCS_DIR := 68endif 69 70$(full_target): PRIVATE_STAGING_DIR := $(staging) 71 72$(full_target): $(sdk_addon_deps) | $(ACP) 73 @echo Packaging SDK Addon: $@ 74 $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs/reference 75 $(hide) if [ -n "$(PRIVATE_DOCS_DIR)" ] ; then \ 76 $(ACP) -r $(PRIVATE_DOCS_DIR)/* $(PRIVATE_STAGING_DIR)/docs/reference ;\ 77 fi 78 $(hide) mkdir -p $(dir $@) 79 $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F * ) 80 81.PHONY: sdk_addon 82sdk_addon: $(full_target) 83 84$(call dist-for-goals, sdk_addon, $(full_target)) 85 86else # addon_name 87ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),) 88$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one) 89endif 90endif # addon_name 91 92