1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//build/config/python.gni") 15import("//build/ohos.gni") 16import("//build/ohos/build_var.gni") 17 18# import target_platform_list 19import("${build_configs_path}/platforms_list.gni") 20group("make_images") { 21 deps = [] 22 foreach(_platform, target_platform_list) { 23 deps += [ 24 ":${_platform}_system_image", 25 ":${_platform}_userdata_image", 26 ":${_platform}_vendor_image", 27 ] 28 if (!is_asan) { 29 deps += [ ":${_platform}_updater_image" ] 30 } 31 if (enable_ramdisk) { 32 deps += [ ":${_platform}_ramdisk_image" ] 33 } 34 } 35} 36 37build_image_tools_path = [ 38 "//out/${device_name}/clang_x64/distributeddatamgr/e2fsprogs", 39 "//out/${device_name}/clang_x64/filemanagement/storage_service", 40 "//third_party/e2fsprogs/prebuilt/host/bin", 41 "//build/ohos/images/mkimage", 42] 43 44foreach(_platform, target_platform_list) { 45 current_platform = _platform 46 current_platform_dir = "${product_output_dir}/$current_platform" 47 48 system_module_info_list = "${current_platform_dir}/system_module_info.json" 49 system_modules_list = "${current_platform_dir}/system_modules_list.txt" 50 51 image_list = [ 52 "system", 53 "vendor", 54 "userdata", 55 "updater", 56 ] 57 if (enable_ramdisk) { 58 image_list += [ "ramdisk" ] 59 } 60 foreach(_image_name, image_list) { 61 action_with_pydeps("${_platform}_${_image_name}_image") { 62 script = "//build/ohos/images/build_image.py" 63 depfile = "$target_gen_dir/$target_name.d" 64 deps = [ "//build/ohos/packages:${_platform}_install_modules" ] 65 66 image_config_file = 67 "//build/ohos/images/mkimage/${_image_name}_image_conf.txt" 68 device_image_config_file = 69 "${product_output_dir}/imagesconf/${_image_name}_image_conf.txt" 70 if (_image_name == "ramdisk") { 71 output_image_file = "$root_build_dir/${_image_name}.img" 72 } else { 73 output_image_file = "$current_platform_dir/images/${_image_name}.img" 74 } 75 image_input_path = "$current_platform_dir/${_image_name}" 76 if (_image_name == "userdata") { 77 image_input_path = "$current_platform_dir/data" 78 } 79 80 sources = [ 81 image_config_file, 82 system_module_info_list, 83 system_modules_list, 84 ] 85 outputs = [ output_image_file ] 86 args = [ 87 "--depfile", 88 rebase_path(depfile, root_build_dir), 89 "--image-name", 90 _image_name, 91 "--input-path", 92 rebase_path(image_input_path, root_build_dir), 93 "--image-config-file", 94 rebase_path(image_config_file, root_build_dir), 95 "--device-image-config-file", 96 rebase_path(device_image_config_file, root_build_dir), 97 "--output-image", 98 rebase_path(output_image_file, root_build_dir), 99 "--target-cpu", 100 target_cpu, 101 "--build-image-tools-path", 102 ] 103 args += rebase_path(build_image_tools_path, root_build_dir) 104 if (sparse_image) { 105 args += [ "--sparse-image" ] 106 } 107 } 108 } 109} 110