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