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 | |
Dan Willemsen | 921f581 | 2018-09-10 15:14:09 -0700 | [diff] [blame] | 15 | .PHONY: sdk_addon |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 16 | |
Colin Cross | d0dbeb3 | 2018-10-22 10:42:44 -0700 | [diff] [blame] | 17 | ifndef ONE_SHOT_MAKEFILE |
| 18 | |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 19 | # If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define |
| 20 | # any of these rules. |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 21 | addon_name := $(PRODUCT_SDK_ADDON_NAME) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 22 | ifneq ($(addon_name),) |
| 23 | |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 24 | addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME) |
| 25 | addon_dir_img := $(addon_dir_leaf)-img |
| 26 | intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates |
| 27 | full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip |
| 28 | full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip |
| 29 | staging := $(intermediates) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 30 | |
| 31 | sdk_addon_deps := |
| 32 | files_to_copy := |
| 33 | |
Raphael | 30e0707 | 2011-02-03 22:59:27 -0800 | [diff] [blame] | 34 | define stub-addon-jar-file |
| 35 | $(subst .jar,_stub-addon.jar,$(1)) |
| 36 | endef |
| 37 | |
| 38 | define stub-addon-jar |
| 39 | $(call stub-addon-jar-file,$(1)): $(1) | mkstubs |
| 40 | $(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS)) |
Colin Cross | 0851df8 | 2017-06-30 13:55:38 -0700 | [diff] [blame] | 41 | $(hide) $(JAVA) -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \ |
Raphael | 30e0707 | 2011-02-03 22:59:27 -0800 | [diff] [blame] | 42 | "$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS) |
| 43 | endef |
| 44 | |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 45 | # Files that are built and then copied into the sdk-addon |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 46 | ifneq ($(PRODUCT_SDK_ADDON_COPY_MODULES),) |
| 47 | $(foreach cf,$(PRODUCT_SDK_ADDON_COPY_MODULES), \ |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 48 | $(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \ |
Raphael | 30e0707 | 2011-02-03 22:59:27 -0800 | [diff] [blame] | 49 | $(eval $(call stub-addon-jar,$(_src))) \ |
| 50 | $(eval _src := $(call stub-addon-jar-file,$(_src))) \ |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 51 | $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \ |
| 52 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 53 | $(eval files_to_copy += $(addon_dir_leaf):$(_src):$(_dest)) \ |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 54 | ) |
| 55 | endif |
| 56 | |
| 57 | # Files that are copied directly into the sdk-addon |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 58 | ifneq ($(PRODUCT_SDK_ADDON_COPY_FILES),) |
| 59 | $(foreach cf,$(PRODUCT_SDK_ADDON_COPY_FILES), \ |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 60 | $(eval _src := $(call word-colon,1,$(cf))) \ |
| 61 | $(eval _dest := $(call word-colon,2,$(cf))) \ |
| 62 | $(if $(findstring images/,$(_dest)), $(eval _root := $(addon_dir_img)), $(eval _root := $(addon_dir_leaf))) \ |
| 63 | $(eval files_to_copy += $(_root):$(_src):$(_dest)) \ |
| 64 | ) |
| 65 | endif |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 66 | |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 67 | # Files copied in the system-image directory |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 68 | files_to_copy += \ |
Bo Hu | bc88ff6 | 2017-08-01 19:02:09 +0000 | [diff] [blame] | 69 | $(addon_dir_img):$(INSTALLED_QEMU_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \ |
bohu | 753e9e4 | 2017-08-10 00:20:01 -0700 | [diff] [blame] | 70 | $(addon_dir_img):$(INSTALLED_QEMU_VENDORIMAGE):images/$(TARGET_CPU_ABI)/vendor.img \ |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 71 | $(addon_dir_img):$(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \ |
| 72 | $(addon_dir_img):$(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \ |
bohu | a83fc0e | 2018-06-25 15:33:14 -0700 | [diff] [blame] | 73 | $(addon_dir_img):device/generic/goldfish/data/etc/userdata.img:images/$(TARGET_CPU_ABI)/userdata.img \ |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 74 | $(addon_dir_img):$(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt \ |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 75 | $(addon_dir_img):$(PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP):images/source.properties |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 76 | |
Matt Wachowski | 9e4d515 | 2018-08-07 16:29:22 -0700 | [diff] [blame] | 77 | |
| 78 | ifeq ($(BOARD_AVB_ENABLE),true) |
| 79 | files_to_copy += \ |
| 80 | $(addon_dir_img):$(QEMU_VERIFIED_BOOT_PARAMS):images/$(TARGET_CPU_ABI)/VerifiedBootParams.textproto |
| 81 | endif |
| 82 | |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 83 | # Generate rules to copy the requested files |
| 84 | $(foreach cf,$(files_to_copy), \ |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 85 | $(eval _root := $(call word-colon,1,$(cf))) \ |
| 86 | $(eval _src := $(call word-colon,2,$(cf))) \ |
| 87 | $(eval _dest := $(call append-path,$(call append-path,$(staging),$(_root)),$(call word-colon,3,$(cf)))) \ |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 88 | $(eval $(call copy-one-file,$(_src),$(_dest))) \ |
| 89 | $(eval sdk_addon_deps += $(_dest)) \ |
| 90 | ) |
| 91 | |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 92 | # The system-image source.properties is a template that we directly expand in-place |
Raphael Moll | a4d1f6a | 2014-10-09 17:48:12 -0700 | [diff] [blame] | 93 | addon_img_source_prop := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)/source.properties |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 94 | sdk_addon_deps += $(addon_img_source_prop) |
| 95 | |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 96 | $(addon_img_source_prop): $(PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP) |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 97 | @echo Generate $@ |
| 98 | $(hide) mkdir -p $(dir $@) |
| 99 | $(hide) sed \ |
| 100 | -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \ |
| 101 | -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \ |
| 102 | -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \ |
| 103 | -e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \ |
| 104 | -e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \ |
| 105 | $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@ |
| 106 | |
| 107 | |
Ying Wang | a032d3d | 2011-11-11 10:52:12 -0800 | [diff] [blame] | 108 | # We don't know about all of the docs files, so depend on the timestamps for |
| 109 | # them, and record the directories, and the packaging rule will just copy the |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 110 | # whole thing. |
Anton Hansson | 8dab0a6 | 2019-03-28 15:45:40 +0000 | [diff] [blame] | 111 | doc_modules := $(PRODUCT_SDK_ADDON_DOC_MODULES) |
Ying Wang | a032d3d | 2011-11-11 10:52:12 -0800 | [diff] [blame] | 112 | sdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm))) |
| 113 | $(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules)) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 114 | |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 115 | $(full_target): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_leaf)) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 116 | |
Dan Willemsen | 288bedf | 2019-05-28 15:36:47 -0700 | [diff] [blame^] | 117 | $(full_target): $(sdk_addon_deps) | $(SOONG_ZIP) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 118 | @echo Packaging SDK Addon: $@ |
Marius Renn | b1df701 | 2011-11-23 18:02:46 -0800 | [diff] [blame] | 119 | $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs |
Ying Wang | a032d3d | 2011-11-11 10:52:12 -0800 | [diff] [blame] | 120 | $(hide) for d in $(PRIVATE_DOCS_DIRS); do \ |
Dan Willemsen | 288bedf | 2019-05-28 15:36:47 -0700 | [diff] [blame^] | 121 | cp -R $$d $(PRIVATE_STAGING_DIR)/docs ;\ |
Ying Wang | a032d3d | 2011-11-11 10:52:12 -0800 | [diff] [blame] | 122 | done |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 123 | $(hide) mkdir -p $(dir $@) |
Jeff Gaston | 25210ce | 2017-09-15 12:34:29 -0700 | [diff] [blame] | 124 | $(hide) $(SOONG_ZIP) -o $@ -C $(dir $(PRIVATE_STAGING_DIR)) -D $(PRIVATE_STAGING_DIR) |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 125 | |
Raphael Moll | a4d1f6a | 2014-10-09 17:48:12 -0700 | [diff] [blame] | 126 | $(full_target_img): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI) |
Dan Willemsen | 288bedf | 2019-05-28 15:36:47 -0700 | [diff] [blame^] | 127 | $(full_target_img): $(full_target) $(addon_img_source_prop) | $(SOONG_ZIP) |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 128 | @echo Packaging SDK Addon System-Image: $@ |
| 129 | $(hide) mkdir -p $(dir $@) |
Dan Willemsen | 288bedf | 2019-05-28 15:36:47 -0700 | [diff] [blame^] | 130 | cp -R $(PRODUCT_OUT)/data $(PRIVATE_STAGING_DIR)/data |
Jeff Gaston | 25210ce | 2017-09-15 12:34:29 -0700 | [diff] [blame] | 131 | $(hide) $(SOONG_ZIP) -o $@ -C $(dir $(PRIVATE_STAGING_DIR)) -D $(PRIVATE_STAGING_DIR) |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 132 | |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 133 | |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 134 | sdk_addon: $(full_target) $(full_target_img) |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 135 | |
Raphael | 3e54830 | 2011-02-23 16:45:57 -0800 | [diff] [blame] | 136 | ifneq ($(sdk_repo_goal),) |
| 137 | # If we're building the sdk_repo, keep the name of the addon zip |
| 138 | # around so that development/build/tools/sdk_repo.mk can dist it |
| 139 | # at the appropriate location. |
Raphael Moll | 0d7d09a | 2014-08-21 15:22:08 -0700 | [diff] [blame] | 140 | ADDON_SDK_ZIP := $(full_target) |
| 141 | ADDON_SDK_IMG_ZIP := $(full_target_img) |
Raphael | 3e54830 | 2011-02-23 16:45:57 -0800 | [diff] [blame] | 142 | else |
| 143 | # When not building an sdk_repo, just dist the addon zip file |
| 144 | # as-is. |
Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 145 | $(call dist-for-goals, sdk_addon, $(full_target)) |
Raphael | 3e54830 | 2011-02-23 16:45:57 -0800 | [diff] [blame] | 146 | endif |
Joe Onorato | eb19b3e | 2009-04-13 16:32:16 -0700 | [diff] [blame] | 147 | |
Joe Onorato | 214a42b | 2009-04-09 20:36:06 -0700 | [diff] [blame] | 148 | else # addon_name |
| 149 | ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),) |
| 150 | $(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one) |
| 151 | endif |
| 152 | endif # addon_name |
Colin Cross | 8b6c94c | 2018-10-01 13:02:08 -0700 | [diff] [blame] | 153 | |
| 154 | endif # !ONE_SHOT_MAKEFILE |