• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  if (is_standard_system) {
23    deps = [
24      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
25      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
26    ]
27    foreach(_platform, target_platform_list) {
28      deps += [
29        ":${_platform}_sys_prod_image",
30        ":${_platform}_system_image",
31        ":${_platform}_userdata_image",
32        ":${_platform}_vendor_image",
33      ]
34      if (enable_ramdisk) {
35        deps += [
36          ":${_platform}_ramdisk_image",
37          ":${_platform}_updater_ramdisk_image",
38        ]
39      } else {
40        deps += [ ":${_platform}_updater_image" ]
41      }
42    }
43    deps += [ ":chip_prod_image" ]
44  } else {
45    deps += [ "//build/ohos/packages:packer" ]
46  }
47}
48
49group("chip_prod_image") {
50  deps = []
51  if (is_standard_system) {
52    deps += [
53      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
54      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
55    ]
56  }
57  foreach(_platform, target_platform_list) {
58    if (chip_product_list == []) {
59      deps += [ ":${_platform}_chip_prod_image" ]
60    } else {
61      foreach(_product, chip_product_list) {
62        deps += [ ":${_platform}_${_product}_chip_prod_image" ]
63      }
64    }
65  }
66}
67
68build_image_tools_path = [
69  "//out/${device_name}/clang_x64/thirdparty/e2fsprogs",
70  "//out/${device_name}/clang_x64/thirdparty/f2fs_tools",
71  "//third_party/e2fsprogs/prebuilt/host/bin",
72  "//build/ohos/images/mkimage",
73]
74
75foreach(_platform, target_platform_list) {
76  current_platform = _platform
77  current_platform_dir = "${product_output_dir}/$current_platform"
78
79  system_module_info_list = "${current_platform_dir}/system_module_info.json"
80  system_modules_list = "${current_platform_dir}/system_modules_list.txt"
81
82  image_list = [
83    "system",
84    "vendor",
85    "userdata",
86    "sys_prod",
87    "chip_prod",
88  ]
89  if (enable_ramdisk) {
90    image_list += [
91      "ramdisk",
92      "updater_ramdisk",
93    ]
94  } else {
95    image_list += [ "updater" ]
96  }
97  foreach(_image_name, image_list) {
98    action_with_pydeps("${_platform}_${_image_name}_image") {
99      script = "//build/ohos/images/build_image.py"
100      depfile = "$target_gen_dir/$target_name.d"
101      deps = [ "//build/ohos/packages:${_platform}_install_modules" ]
102      if (!asan_detector) {
103        deps += [ "//build/ohos/packages:high_privilege_process_validate" ]
104      }
105
106      image_config_file =
107          "//build/ohos/images/mkimage/${_image_name}_image_conf.txt"
108      if (is_debug) {
109        image_config_file =
110            "//build/ohos/images/mkimage/debug/${_image_name}_image_conf.txt"
111      }
112      device_image_config_file =
113          "${product_output_dir}/imagesconf/${_image_name}_image_conf.txt"
114      if (_image_name == "ramdisk" || _image_name == "updater_ramdisk") {
115        output_image_file = "$root_build_dir/${_image_name}.img"
116      } else {
117        output_image_file = "$current_platform_dir/images/${_image_name}.img"
118      }
119      if (_image_name == "updater_ramdisk") {
120        image_input_path = "$current_platform_dir/updater"
121      } else {
122        image_input_path = "$current_platform_dir/${_image_name}"
123      }
124      if (_image_name == "userdata") {
125        image_input_path = "$current_platform_dir/data"
126      }
127
128      sources = [
129        image_config_file,
130        system_module_info_list,
131        system_modules_list,
132      ]
133      outputs = [ output_image_file ]
134      args = [
135        "--depfile",
136        rebase_path(depfile, root_build_dir),
137        "--image-name",
138        _image_name,
139        "--input-path",
140        rebase_path(image_input_path, root_build_dir),
141        "--image-config-file",
142        rebase_path(image_config_file, root_build_dir),
143        "--device-image-config-file",
144        rebase_path(device_image_config_file, root_build_dir),
145        "--output-image",
146        rebase_path(output_image_file, root_build_dir),
147        "--target-cpu",
148        target_cpu,
149        "--build-image-tools-path",
150      ]
151      args += rebase_path(build_image_tools_path, root_build_dir)
152      if (sparse_image) {
153        args += [ "--sparse-image" ]
154      }
155    }
156  }
157
158  # Used to generate chip_prod images of different products
159  foreach(_product, chip_product_list) {
160    _image_name = "chip_prod"
161    action_with_pydeps("${_platform}_${_product}_chip_prod_image") {
162      script = "//build/ohos/images/build_image.py"
163      depfile = "$target_gen_dir/$target_name.d"
164      deps = [ "//build/ohos/packages:${_platform}_install_modules" ]
165
166      image_config_file =
167          "//build/ohos/images/mkimage/${_image_name}_image_conf.txt"
168      device_image_config_file =
169          "${product_output_dir}/imagesconf/${_image_name}_image_conf.txt"
170      image_input_path = "${current_platform_dir}/${_image_name}/${_product}"
171      output_image_file =
172          "${current_platform_dir}/images/${_product}/${_image_name}.img"
173
174      sources = [
175        image_config_file,
176        system_module_info_list,
177        system_modules_list,
178      ]
179      outputs = [ output_image_file ]
180
181      args = [
182        "--depfile",
183        rebase_path(depfile, root_build_dir),
184        "--image-name",
185        _image_name,
186        "--input-path",
187        rebase_path(image_input_path, root_build_dir),
188        "--image-config-file",
189        rebase_path(image_config_file, root_build_dir),
190        "--device-image-config-file",
191        rebase_path(device_image_config_file, root_build_dir),
192        "--output-image",
193        rebase_path(output_image_file, root_build_dir),
194        "--target-cpu",
195        target_cpu,
196        "--build-image-tools-path",
197      ]
198      args += rebase_path(build_image_tools_path, root_build_dir)
199      if (sparse_image) {
200        args += [ "--sparse-image" ]
201      }
202    }
203  }
204}