build_custom_images.mk revision 4540a85dd434f91ebf4533e7a59691d460967568
1#
2# Copyright (C) 2015 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# Build additional images requested by the product makefile.
18# This script gives the ability to build multiple additional images and you can
19# configure what modules/files to include in each image.
20# 1. Define PRODUCT_CUSTOM_IMAGE_MAKEFILES in your product makefile.
21#    PRODUCT_CUSTOM_IMAGE_MAKEFILES is a list of makefiles.
22#    Each makefile configures an image.
23#    For image configuration makefile foo/bar/xyz.mk, the built image file name
24#    will be xyz.img. So make sure they won't conflict.
25# 2. In each image's configuration makefile, you can define variables:
26#   - CUSTOM_IMAGE_MOUNT_POINT, the mount point, such as "oem", "odm" etc.
27#   - CUSTOM_IMAGE_PARTITION_SIZE
28#   - CUSTOM_IMAGE_FILE_SYSTEM_TYPE
29#   - CUSTOM_IMAGE_DICT_FILE, a text file defines a dictionary accepted by
30#     BuildImage() in tools/releasetools/build_image.py.
31#   - CUSTOM_IMAGE_MODULES, a list of module names you want to include in
32#     the image; Not only the module itself will be installed to proper path in
33#     the image, you can also piggyback additional files/directories with the
34#     module's LOCAL_PICKUP_FILES.
35#   - CUSTOM_IMAGE_COPY_FILES, a list of "<src>:<dest>" to be copied to the
36#     image. <dest> is relativ to the root of the image.
37#
38# To build all those images, run "make custom_images".
39
40ifneq ($(filter $(MAKECMDGOALS),custom_images),)
41
42.PHONY: custom_images
43
44custom_image_parameter_variables := \
45  CUSTOM_IMAGE_MOUNT_POINT \
46  CUSTOM_IMAGE_PARTITION_SIZE \
47  CUSTOM_IMAGE_FILE_SYSTEM_TYPE \
48  CUSTOM_IMAGE_DICT_FILE \
49  CUSTOM_IMAGE_MODULES \
50  CUSTOM_IMAGE_COPY_FILES \
51
52# We don't expect product makefile to inherit/override PRODUCT_CUSTOM_IMAGE_MAKEFILES,
53# so we don't put it in the _product_var_list.
54$(foreach mk, $(PRODUCT_CUSTOM_IMAGE_MAKEFILES),\
55  $(eval my_custom_imag_makefile := $(mk))\
56  $(eval include $(BUILD_SYSTEM)/tasks/tools/build_custom_image.mk))
57
58endif
59