From e1d191ee956674147ac1b34129d1f2df322fc3ae Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Thu, 17 May 2012 11:32:26 -0700 Subject: [PATCH] Add rules to build the factory bundle. Change-Id: I66bda914a5bd41bda7c8a4314f658924087e2bfb --- core/main.mk | 4 +++ core/product.mk | 1 + core/tasks/factory_bundle.mk | 80 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 core/tasks/factory_bundle.mk diff --git a/core/main.mk b/core/main.mk index 89cbc6359..a9e50e43a 100644 --- a/core/main.mk +++ b/core/main.mk @@ -736,6 +736,9 @@ ramdisk: $(INSTALLED_RAMDISK_TARGET) .PHONY: factory_ramdisk factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET) +.PHONY: factory_bundle +factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET) + .PHONY: systemtarball systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET) @@ -813,6 +816,7 @@ else # TARGET_BUILD_APPS $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ $(INSTALLED_RAMDISK_TARGET) \ $(INSTALLED_FACTORY_RAMDISK_TARGET) \ + $(INSTALLED_FACTORY_BUNDLE_TARGET) \ ) # Building a full system-- the default is to build droidcore diff --git a/core/product.mk b/core/product.mk index 4d4c98340..283b6efe3 100644 --- a/core/product.mk +++ b/core/product.mk @@ -85,6 +85,7 @@ _product_var_list := \ PRODUCT_DEFAULT_WIFI_CHANNELS \ PRODUCT_DEFAULT_DEV_CERTIFICATE \ PRODUCT_FACTORY_RAMDISK_MODULES \ + PRODUCT_FACTORY_BUNDLE_MODULES define dump-product diff --git a/core/tasks/factory_bundle.mk b/core/tasks/factory_bundle.mk new file mode 100644 index 000000000..2a1ac2908 --- /dev/null +++ b/core/tasks/factory_bundle.mk @@ -0,0 +1,80 @@ +# +# Copyright (C) 2011 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +ifeq (,$(ONE_SHOT_MAKEFILE)) + +# PRODUCT_FACTORY_RAMDISK_MODULES consists of ":[:...]" tuples. +# is relative to the staging directory for the bundle. +# +# Only host modules can be installed here. +# (It's possible to relax this, but it's not needed and kind of tricky. We'll need to add +# a better way of specifying the class. Really the answer is to stop having modules with +# duplicate names) +# +# You can also add files with PRODUCT_COPY_FILES if necessary. +# +# For example: +# PRODUCT_FACTORY_BUNDLE_MODULES := \ +# adb:adb fastboot:fastboot +requested_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_BUNDLE_MODULES)) + +root_dir := $(PRODUCT_OUT)/factory_bundle +leaf := $(strip $(TARGET_PRODUCT))-factory_bundle-$(FILE_NAME_TAG) +named_dir := $(PRODUCT_OUT)/$(leaf) +tarball := $(PRODUCT_OUT)/$(leaf).tgz + +copied_files := \ + $(foreach _fb_m, $(requested_modules), $(strip \ + $(eval _fb_m_tuple := $(subst :, ,$(_fb_m))) \ + $(eval _fb_m_name := $(word 1,$(_fb_m_tuple))) \ + $(eval _fb_dests := $(wordlist 2,999,$(_fb_m_tuple))) \ + $(eval _fb_m_built := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(_fb_m_name).BUILT))) \ + $(if $(_fb_m_built),,$(error no built file in requested_modules for '$(_fb_m_built)'))\ + $(foreach _fb_f,$(_fb_dests),$(eval $(call copy-one-file,$(_fb_m_built),$(root_dir)/$(_fb_f))))\ + $(addprefix $(root_dir)/,$(_fb_dests)) \ + )) \ + $(filter $(root_dir)/%, $(ALL_DEFAULT_INSTALLED_MODULES)) + +ifneq (,$(strip $(copied_files))) + +# +# These files are made by magic so we need to explicitly include them +# +$(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(root_dir)/factory/build.prop)) +copied_files += $(root_dir)/factory/build.prop + +$(eval $(call copy-one-file,$(PRODUCT_OUT)/factory_ramdisk.img,$(root_dir)/factory_ramdisk.img)) +copied_files += $(root_dir)/factory_ramdisk.img +# +# End magic +# + +$(tarball): PRIVATE_ROOT_DIR := $(root_dir) +$(tarball): PRIVATE_NAMED_DIR := $(named_dir) + +$(tarball): $(copied_files) + @echo "Tarball: $@" + $(hide) rm -rf $(PRIVATE_NAMED_DIR) + $(hide) ( cp -r $(PRIVATE_ROOT_DIR) $(PRIVATE_NAMED_DIR) \ + && tar cfz $@ -C $(dir $(PRIVATE_NAMED_DIR)) $(notdir $(PRIVATE_NAMED_DIR)) \ + ) && rm -rf $(PRIVATE_NAMED_DIR) + +INSTALLED_FACTORY_BUNDLE_TARGET := $(tarball) + +endif + +endif # ONE_SHOT_MAKEFILE + -- 2.11.0