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