OSDN Git Service

am b528116b: am dd243370: apicheck: Suppress certain changes in final qualifier.
[android-x86/build.git] / core / tasks / factory_ramdisk.mk
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 ifeq (,$(ONE_SHOT_MAKEFILE))
18 ifneq ($(TARGET_BUILD_PDK),true)
19   TARGET_BUILD_FACTORY=true
20 endif
21 ifeq ($(TARGET_BUILD_FACTORY),true)
22
23 # PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
24 # <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
25 # We can have multiple <install_path>s because multiple modules may have the same name.
26 # For example:
27 # PRODUCT_FACTORY_RAMDISK_MODULES := \
28 #     toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb
29 factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
30 ifneq (,$(factory_ramdisk_modules))
31
32 # A module name may end up in multiple modules (so multiple built files)
33 # with the same name.
34 # This function selects the module built file based on the install path.
35 # $(1): the dest install path
36 # $(2): the module built files
37 define install-one-factory-ramdisk-module
38 $(eval _iofrm_suffix := $(suffix $(1))) \
39 $(if $(_iofrm_suffix), \
40     $(eval _iofrm_pattern := %$(_iofrm_suffix)), \
41     $(eval _iofrm_pattern := %$(notdir $(1)))) \
42 $(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \
43 $(if $(filter 1,$(words $(_iofrm_src))), \
44     $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \
45     $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \
46     $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \
47     $(error Error: Cannot find match in "$(2)" for "$(1)") \
48     )
49 endef
50
51 INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
52 $(foreach m, $(factory_ramdisk_modules), \
53     $(eval _fr_m_tuple := $(subst :, ,$(m))) \
54     $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \
55     $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \
56     $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \
57     $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \
58     )
59 endif
60
61 # Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
62 INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
63     $(ALL_DEFAULT_INSTALLED_MODULES))
64
65 ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
66
67 # These files are made by magic in build/core/Makefile so we need to explicitly include them
68 $(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop))
69 INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop
70
71 BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz
72 BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
73
74 INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS)
75 $(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \
76     $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
77         $(call pretty,"Target factory ram disk file system: $@")
78         $(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
79
80 TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET)
81 INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
82 ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT))
83   RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)"
84 else
85   RAMDISK_CMDLINE :=
86 endif
87 $(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTIMG) $(TARGET_RAMDISK_KERNEL) $(INSTALLED_FACTORY_RAMDISK_FS)
88         $(call pretty,"Target factory ram disk img format: $@")
89         $(MKBOOTIMG) --kernel $(TARGET_RAMDISK_KERNEL) --ramdisk $(INSTALLED_FACTORY_RAMDISK_FS) \
90             --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@
91
92 endif
93
94 endif # TARGET_BUILD_PDK
95 endif # ONE_SHOT_MAKEFILE