factory_ramdisk.mk revision 0d75a0a54c5ecc0dd1580a7c3da0e0b0aa49bd25
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>" pairs.
18# <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
19# For example:
20# PRODUCT_FACTORY_RAMDISK_MODULES := \
21#     toolbox:bin/toolbox adbd:sbin/adbd adb:bin/adb
22factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
23ifneq (,$(factory_ramdisk_modules))
24INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
25$(foreach m, $(factory_ramdisk_modules), \
26    $(eval _fr_m_name := $(call word-colon,1,$(m))) \
27    $(eval _fr_dest := $(call word-colon,2,$(m))) \
28    $(eval _fr_m_built := $(filter-out %.a, $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT)))) \
29    $(if $(_fr_m_built), \
30        $(if $(filter-out 1, $(words $(_fr_m_built))), \
31            $(error Error: module "$(m)" has multiple built files: "$(_fr_m_built)")) \
32        $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(_fr_dest)) \
33        $(eval $(call copy-one-file,$(_fr_m_built),$(_fulldest))) \
34        $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \
35        $(error Error: module "$(m)" in PRODUCT_FACTORY_RAMDISK_MODULES is not a target module!) \
36    ))
37endif
38
39# Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
40INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
41    $(ALL_DEFAULT_INSTALLED_MODULES))
42
43ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
44
45BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
46
47INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
48$(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTFS) \
49    $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
50	$(call pretty,"Target factory ram disk: $@")
51	$(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
52
53endif
54