factory_ramdisk.mk revision c16dbcd8c8518fe19a87c5ec71866e0336a2cf5d
1# 2# Copyright (C) 2011 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples. 18# <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT. 19# We can have multiple <install_path>s because multiple modules may have the same name. 20# For example: 21# PRODUCT_FACTORY_RAMDISK_MODULES := \ 22# toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb 23factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES)) 24ifneq (,$(factory_ramdisk_modules)) 25 26# A module name may end up in multiple modules (so multiple built files) 27# with the same name. 28# This function selects the module built file based on the install path. 29# $(1): the dest install path 30# $(2): the module built files 31define install-one-factory-ramdisk-module 32$(eval _iofrm_suffix := $(suffix $(1))) \ 33$(if $(_iofrm_suffix), \ 34 $(eval _iofrm_pattern := %$(_iofrm_suffix)), \ 35 $(eval _iofrm_pattern := %$(notdir $(1)))) \ 36$(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \ 37$(if $(filter 1,$(words $(_iofrm_src))), \ 38 $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \ 39 $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \ 40 $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \ 41 $(error Error: Can not find match in "$(2)" for "$(1)") \ 42 ) 43endef 44 45INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES := 46$(foreach m, $(factory_ramdisk_modules), \ 47 $(eval _fr_m_tuple := $(subst :, ,$(m))) \ 48 $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \ 49 $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \ 50 $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \ 51 $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \ 52 ) 53endif 54 55# Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc. 56INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \ 57 $(ALL_DEFAULT_INSTALLED_MODULES)) 58 59ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES)) 60 61BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img 62 63INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET) 64$(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTFS) \ 65 $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP) 66 $(call pretty,"Target factory ram disk: $@") 67 $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@ 68 69endif 70