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