2009-04-10 11:36:06 +08:00
|
|
|
# Copyright (C) 2009 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2018-09-11 06:14:09 +08:00
|
|
|
.PHONY: sdk_addon
|
2009-04-10 11:36:06 +08:00
|
|
|
|
|
|
|
# If they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define
|
|
|
|
# any of these rules.
|
2019-03-28 23:45:40 +08:00
|
|
|
addon_name := $(PRODUCT_SDK_ADDON_NAME)
|
2009-04-10 11:36:06 +08:00
|
|
|
ifneq ($(addon_name),)
|
|
|
|
|
2014-08-22 06:22:08 +08:00
|
|
|
addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME)
|
|
|
|
addon_dir_img := $(addon_dir_leaf)-img
|
|
|
|
intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates
|
|
|
|
full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip
|
|
|
|
full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip
|
|
|
|
staging := $(intermediates)
|
2009-04-10 11:36:06 +08:00
|
|
|
|
|
|
|
sdk_addon_deps :=
|
|
|
|
files_to_copy :=
|
|
|
|
|
2011-02-04 14:59:27 +08:00
|
|
|
define stub-addon-jar-file
|
|
|
|
$(subst .jar,_stub-addon.jar,$(1))
|
|
|
|
endef
|
|
|
|
|
|
|
|
define stub-addon-jar
|
|
|
|
$(call stub-addon-jar-file,$(1)): $(1) | mkstubs
|
|
|
|
$(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS))
|
2017-07-01 04:55:38 +08:00
|
|
|
$(hide) $(JAVA) -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \
|
2011-02-04 14:59:27 +08:00
|
|
|
"$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS)
|
|
|
|
endef
|
|
|
|
|
2009-04-10 11:36:06 +08:00
|
|
|
# Files that are built and then copied into the sdk-addon
|
2019-03-28 23:45:40 +08:00
|
|
|
ifneq ($(PRODUCT_SDK_ADDON_COPY_MODULES),)
|
|
|
|
$(foreach cf,$(PRODUCT_SDK_ADDON_COPY_MODULES), \
|
2009-04-10 11:36:06 +08:00
|
|
|
$(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \
|
2011-02-04 14:59:27 +08:00
|
|
|
$(eval $(call stub-addon-jar,$(_src))) \
|
|
|
|
$(eval _src := $(call stub-addon-jar-file,$(_src))) \
|
2009-04-10 11:36:06 +08:00
|
|
|
$(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \
|
|
|
|
$(eval _dest := $(call word-colon,2,$(cf))) \
|
2014-08-22 06:22:08 +08:00
|
|
|
$(eval files_to_copy += $(addon_dir_leaf):$(_src):$(_dest)) \
|
2009-04-10 11:36:06 +08:00
|
|
|
)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Files that are copied directly into the sdk-addon
|
2019-03-28 23:45:40 +08:00
|
|
|
ifneq ($(PRODUCT_SDK_ADDON_COPY_FILES),)
|
|
|
|
$(foreach cf,$(PRODUCT_SDK_ADDON_COPY_FILES), \
|
2014-08-22 06:22:08 +08:00
|
|
|
$(eval _src := $(call word-colon,1,$(cf))) \
|
|
|
|
$(eval _dest := $(call word-colon,2,$(cf))) \
|
|
|
|
$(if $(findstring images/,$(_dest)), $(eval _root := $(addon_dir_img)), $(eval _root := $(addon_dir_leaf))) \
|
|
|
|
$(eval files_to_copy += $(_root):$(_src):$(_dest)) \
|
|
|
|
)
|
|
|
|
endif
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2014-08-22 06:22:08 +08:00
|
|
|
# Files copied in the system-image directory
|
2009-04-10 11:36:06 +08:00
|
|
|
files_to_copy += \
|
2017-08-02 03:02:09 +08:00
|
|
|
$(addon_dir_img):$(INSTALLED_QEMU_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
|
2017-08-10 15:20:01 +08:00
|
|
|
$(addon_dir_img):$(INSTALLED_QEMU_VENDORIMAGE):images/$(TARGET_CPU_ABI)/vendor.img \
|
2020-03-31 11:16:13 +08:00
|
|
|
$(addon_dir_img):$(INSTALLED_QEMU_RAMDISKIMAGE):images/$(TARGET_CPU_ABI)/ramdisk.img \
|
2014-08-22 06:22:08 +08:00
|
|
|
$(addon_dir_img):$(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
|
2018-06-26 06:33:14 +08:00
|
|
|
$(addon_dir_img):device/generic/goldfish/data/etc/userdata.img:images/$(TARGET_CPU_ABI)/userdata.img \
|
2014-08-22 06:22:08 +08:00
|
|
|
$(addon_dir_img):$(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt \
|
2019-03-28 23:45:40 +08:00
|
|
|
$(addon_dir_img):$(PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP):images/source.properties
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2018-08-08 07:29:22 +08:00
|
|
|
|
|
|
|
ifeq ($(BOARD_AVB_ENABLE),true)
|
|
|
|
files_to_copy += \
|
|
|
|
$(addon_dir_img):$(QEMU_VERIFIED_BOOT_PARAMS):images/$(TARGET_CPU_ABI)/VerifiedBootParams.textproto
|
|
|
|
endif
|
|
|
|
|
2009-04-10 11:36:06 +08:00
|
|
|
# Generate rules to copy the requested files
|
|
|
|
$(foreach cf,$(files_to_copy), \
|
2014-08-22 06:22:08 +08:00
|
|
|
$(eval _root := $(call word-colon,1,$(cf))) \
|
|
|
|
$(eval _src := $(call word-colon,2,$(cf))) \
|
|
|
|
$(eval _dest := $(call append-path,$(call append-path,$(staging),$(_root)),$(call word-colon,3,$(cf)))) \
|
2009-04-10 11:36:06 +08:00
|
|
|
$(eval $(call copy-one-file,$(_src),$(_dest))) \
|
|
|
|
$(eval sdk_addon_deps += $(_dest)) \
|
|
|
|
)
|
|
|
|
|
2014-08-22 06:22:08 +08:00
|
|
|
# The system-image source.properties is a template that we directly expand in-place
|
2014-10-10 08:48:12 +08:00
|
|
|
addon_img_source_prop := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)/source.properties
|
2014-08-22 06:22:08 +08:00
|
|
|
sdk_addon_deps += $(addon_img_source_prop)
|
|
|
|
|
2019-03-28 23:45:40 +08:00
|
|
|
$(addon_img_source_prop): $(PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP)
|
2014-08-22 06:22:08 +08:00
|
|
|
@echo Generate $@
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
|
|
|
$(hide) sed \
|
|
|
|
-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
|
|
|
|
-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
|
|
|
|
-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
|
|
|
|
-e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \
|
|
|
|
-e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \
|
|
|
|
$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
|
|
|
|
|
|
|
|
|
2011-11-12 02:52:12 +08:00
|
|
|
# We don't know about all of the docs files, so depend on the timestamps for
|
|
|
|
# them, and record the directories, and the packaging rule will just copy the
|
2009-04-10 11:36:06 +08:00
|
|
|
# whole thing.
|
2019-03-28 23:45:40 +08:00
|
|
|
doc_modules := $(PRODUCT_SDK_ADDON_DOC_MODULES)
|
2011-11-12 02:52:12 +08:00
|
|
|
sdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm)))
|
|
|
|
$(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules))
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2014-08-22 06:22:08 +08:00
|
|
|
$(full_target): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_leaf))
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2019-05-29 06:36:47 +08:00
|
|
|
$(full_target): $(sdk_addon_deps) | $(SOONG_ZIP)
|
2009-04-10 11:36:06 +08:00
|
|
|
@echo Packaging SDK Addon: $@
|
2011-11-24 10:02:46 +08:00
|
|
|
$(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs
|
2011-11-12 02:52:12 +08:00
|
|
|
$(hide) for d in $(PRIVATE_DOCS_DIRS); do \
|
2019-05-29 06:36:47 +08:00
|
|
|
cp -R $$d $(PRIVATE_STAGING_DIR)/docs ;\
|
2011-11-12 02:52:12 +08:00
|
|
|
done
|
2009-04-10 11:36:06 +08:00
|
|
|
$(hide) mkdir -p $(dir $@)
|
2017-09-16 03:34:29 +08:00
|
|
|
$(hide) $(SOONG_ZIP) -o $@ -C $(dir $(PRIVATE_STAGING_DIR)) -D $(PRIVATE_STAGING_DIR)
|
2014-08-22 06:22:08 +08:00
|
|
|
|
2014-10-10 08:48:12 +08:00
|
|
|
$(full_target_img): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)
|
2019-05-29 06:36:47 +08:00
|
|
|
$(full_target_img): $(full_target) $(addon_img_source_prop) | $(SOONG_ZIP)
|
2014-08-22 06:22:08 +08:00
|
|
|
@echo Packaging SDK Addon System-Image: $@
|
|
|
|
$(hide) mkdir -p $(dir $@)
|
2019-05-29 06:36:47 +08:00
|
|
|
cp -R $(PRODUCT_OUT)/data $(PRIVATE_STAGING_DIR)/data
|
2017-09-16 03:34:29 +08:00
|
|
|
$(hide) $(SOONG_ZIP) -o $@ -C $(dir $(PRIVATE_STAGING_DIR)) -D $(PRIVATE_STAGING_DIR)
|
2014-08-22 06:22:08 +08:00
|
|
|
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2014-08-22 06:22:08 +08:00
|
|
|
sdk_addon: $(full_target) $(full_target_img)
|
2009-04-10 11:36:06 +08:00
|
|
|
|
2011-02-24 08:45:57 +08:00
|
|
|
ifneq ($(sdk_repo_goal),)
|
|
|
|
# If we're building the sdk_repo, keep the name of the addon zip
|
|
|
|
# around so that development/build/tools/sdk_repo.mk can dist it
|
|
|
|
# at the appropriate location.
|
2014-08-22 06:22:08 +08:00
|
|
|
ADDON_SDK_ZIP := $(full_target)
|
|
|
|
ADDON_SDK_IMG_ZIP := $(full_target_img)
|
2011-02-24 08:45:57 +08:00
|
|
|
else
|
|
|
|
# When not building an sdk_repo, just dist the addon zip file
|
|
|
|
# as-is.
|
2009-04-14 07:32:16 +08:00
|
|
|
$(call dist-for-goals, sdk_addon, $(full_target))
|
2011-02-24 08:45:57 +08:00
|
|
|
endif
|
2009-04-14 07:32:16 +08:00
|
|
|
|
2009-04-10 11:36:06 +08:00
|
|
|
else # addon_name
|
|
|
|
ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
|
|
|
|
$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
|
|
|
|
endif
|
|
|
|
endif # addon_name
|