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