factory_bundle.mk revision a1712eea02622e737533e82dcd622a0ce2da195b
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
17ifeq (,$(ONE_SHOT_MAKEFILE))
18ifneq ($(TARGET_BUILD_PDK),true)
19
20# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
21# <install_path> is relative to the staging directory for the bundle.
22# 
23# Only host modules can be installed here. 
24# (It's possible to relax this, but it's not needed and kind of tricky.  We'll need to add
25# a better way of specifying the class. Really the answer is to stop having modules with
26# duplicate names)
27#
28# You can also add files with PRODUCT_COPY_FILES if necessary.
29#
30# For example:
31# PRODUCT_FACTORY_BUNDLE_MODULES := \
32#     adb:adb fastboot:fastboot
33requested_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_BUNDLE_MODULES))
34
35root_dir := $(PRODUCT_OUT)/factory_bundle
36leaf := $(strip $(TARGET_PRODUCT))-factory_bundle-$(FILE_NAME_TAG)
37named_dir := $(PRODUCT_OUT)/$(leaf)
38tarball := $(PRODUCT_OUT)/$(leaf).tgz
39
40copied_files := \
41  $(foreach _fb_m, $(requested_modules), $(strip \
42    $(eval _fb_m_tuple := $(subst :, ,$(_fb_m))) \
43    $(eval _fb_m_name := $(word 1,$(_fb_m_tuple))) \
44    $(eval _fb_dests := $(wordlist 2,999,$(_fb_m_tuple))) \
45    $(eval _fb_m_built := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(_fb_m_name).BUILT))) \
46    $(if $(_fb_m_built),,$(error no built file in requested_modules for '$(_fb_m_built)'))\
47    $(foreach _fb_f,$(_fb_dests),$(eval $(call copy-one-file,$(_fb_m_built),$(root_dir)/$(_fb_f))))\
48    $(addprefix $(root_dir)/,$(_fb_dests)) \
49    )) \
50  $(filter $(root_dir)/%, $(ALL_DEFAULT_INSTALLED_MODULES))
51
52ifneq (,$(strip $(copied_files)))
53
54#
55# These files are made by magic so we need to explicitly include them
56#
57$(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(root_dir)/build.prop))
58copied_files += $(root_dir)/build.prop
59
60$(eval $(call copy-one-file,$(PRODUCT_OUT)/factory_ramdisk.img,$(root_dir)/factory_ramdisk.img))
61copied_files += $(root_dir)/factory_ramdisk.img
62#
63# End magic
64#
65
66$(tarball): PRIVATE_ROOT_DIR := $(root_dir)
67$(tarball): PRIVATE_NAMED_DIR := $(named_dir)
68
69$(tarball): $(copied_files)
70	@echo "Tarball: $@"
71	$(hide) rm -rf $(PRIVATE_NAMED_DIR)
72	$(hide) ( cp -r $(PRIVATE_ROOT_DIR) $(PRIVATE_NAMED_DIR) \
73			&& tar cfz $@ -C $(dir $(PRIVATE_NAMED_DIR)) $(notdir $(PRIVATE_NAMED_DIR)) \
74			) && rm -rf $(PRIVATE_NAMED_DIR)
75
76INSTALLED_FACTORY_BUNDLE_TARGET := $(tarball)
77
78endif
79
80endif # TARGET_BUILD_PDK
81endif # ONE_SHOT_MAKEFILE
82
83