| 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 |  | 
| Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 21 | addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME) | 
|  | 22 |  | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 23 | intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates | 
| Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 24 | full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip | 
|  | 25 | staging := $(intermediates)/$(addon_dir_leaf) | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 26 |  | 
|  | 27 | sdk_addon_deps := | 
|  | 28 | files_to_copy := | 
|  | 29 |  | 
| Raphael | 843c6e2 | 2011-02-03 22:59:27 -0800 | [diff] [blame] | 30 | define stub-addon-jar-file | 
|  | 31 | $(subst .jar,_stub-addon.jar,$(1)) | 
|  | 32 | endef | 
|  | 33 |  | 
|  | 34 | define 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) | 
|  | 39 | endef | 
|  | 40 |  | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 41 | # Files that are built and then copied into the sdk-addon | 
|  | 42 | ifneq ($(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)))) \ | 
| Raphael | 843c6e2 | 2011-02-03 22:59:27 -0800 | [diff] [blame] | 45 | $(eval $(call stub-addon-jar,$(_src))) \ | 
|  | 46 | $(eval _src := $(call stub-addon-jar-file,$(_src))) \ | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 47 | $(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 | ) | 
|  | 51 | endif | 
|  | 52 |  | 
|  | 53 | # Files that are copied directly into the sdk-addon | 
|  | 54 | files_to_copy += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES) | 
|  | 55 |  | 
|  | 56 | # All SDK add-ons have these files | 
|  | 57 | files_to_copy += \ | 
| Bruce Beare | 18a130e | 2011-02-18 15:06:20 -0800 | [diff] [blame] | 58 | $(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 \ | 
|  | 61 | $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 62 |  | 
|  | 63 | # Generate rules to copy the requested files | 
|  | 64 | $(foreach cf,$(files_to_copy), \ | 
|  | 65 | $(eval _src := $(call word-colon,1,$(cf))) \ | 
|  | 66 | $(eval _dest := $(call append-path,$(staging),$(call word-colon,2,$(cf)))) \ | 
|  | 67 | $(eval $(call copy-one-file,$(_src),$(_dest))) \ | 
|  | 68 | $(eval sdk_addon_deps += $(_dest)) \ | 
|  | 69 | ) | 
|  | 70 |  | 
|  | 71 | # We don't know about all of the docs files, so depend on the timestamp for | 
|  | 72 | # that, and record the directory, and the packaging rule will just copy the | 
|  | 73 | # whole thing. | 
|  | 74 | doc_module := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_DOC_MODULE)) | 
|  | 75 | ifneq ($(doc_module),) | 
|  | 76 | doc_timestamp := $(call doc-timestamp-for, $(doc_module)) | 
|  | 77 | sdk_addon_deps += $(doc_timestamp) | 
|  | 78 | $(full_target): PRIVATE_DOCS_DIR := $(OUT_DOCS)/$(doc_module) | 
|  | 79 | else | 
|  | 80 | $(full_target): PRIVATE_DOCS_DIR := | 
|  | 81 | endif | 
|  | 82 |  | 
|  | 83 | $(full_target): PRIVATE_STAGING_DIR := $(staging) | 
|  | 84 |  | 
|  | 85 | $(full_target): $(sdk_addon_deps) | $(ACP) | 
|  | 86 | @echo Packaging SDK Addon: $@ | 
|  | 87 | $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs/reference | 
|  | 88 | $(hide) if [ -n "$(PRIVATE_DOCS_DIR)" ] ; then \ | 
|  | 89 | $(ACP) -r $(PRIVATE_DOCS_DIR)/* $(PRIVATE_STAGING_DIR)/docs/reference ;\ | 
|  | 90 | fi | 
|  | 91 | $(hide) mkdir -p $(dir $@) | 
| Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 92 | $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F * ) | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 93 |  | 
|  | 94 | .PHONY: sdk_addon | 
|  | 95 | sdk_addon: $(full_target) | 
|  | 96 |  | 
| Raphael | bd0c91c | 2011-02-15 16:09:36 -0800 | [diff] [blame] | 97 | # Keep the name of the addon final zip around for sdk_repo. | 
|  | 98 | # This is used by development/build/tools/sdk_repo.mk. | 
|  | 99 | ADDON_SDK_ZIP := $(full_target) | 
|  | 100 |  | 
| Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 101 | $(call dist-for-goals, sdk_addon, $(full_target)) | 
|  | 102 |  | 
| Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 103 | else # addon_name | 
|  | 104 | ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),) | 
|  | 105 | $(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one) | 
|  | 106 | endif | 
|  | 107 | endif # addon_name | 
|  | 108 |  |