• 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}_eng_chipset_image",
30        ":${_platform}_eng_system_image",
31        ":${_platform}_sys_prod_image",
32        ":${_platform}_system_image",
33        ":${_platform}_updater_ramdisk_image",
34        ":${_platform}_userdata_image",
35        ":${_platform}_vendor_image",
36      ]
37      if (enable_ramdisk) {
38        deps += [ ":${_platform}_ramdisk_image" ]
39      }
40    }
41    deps += [ ":chip_prod_image" ]
42  } else {
43    deps += [ "//build/ohos/packages:packer" ]
44  }
45}
46
47group("eng_system_image") {
48  deps = []
49  if (is_standard_system) {
50    deps += [
51      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
52      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
53    ]
54  }
55  foreach(_platform, target_platform_list) {
56    deps += [ ":${_platform}_eng_system_image" ]
57  }
58}
59
60group("eng_chipset_image") {
61  deps = []
62  if (is_standard_system) {
63    deps += [
64      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
65      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
66    ]
67  }
68  foreach(_platform, target_platform_list) {
69    deps += [ ":${_platform}_eng_chipset_image" ]
70  }
71}
72
73group("chip_prod_image") {
74  deps = []
75  if (is_standard_system) {
76    deps += [
77      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
78      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
79    ]
80  }
81  foreach(_platform, target_platform_list) {
82    if (chip_product_list == []) {
83      deps += [ ":${_platform}_chip_prod_image" ]
84    } else {
85      foreach(_product, chip_product_list) {
86        deps += [ ":${_platform}_${_product}_chip_prod_image" ]
87      }
88    }
89  }
90}
91
92group("sys_prod_image") {
93  deps = []
94  if (is_standard_system) {
95    deps += [
96      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
97      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
98    ]
99  }
100  foreach(_platform, target_platform_list) {
101    deps += [ ":${_platform}_sys_prod_image" ]
102  }
103}
104
105group("system_image") {
106  deps = []
107  if (is_standard_system) {
108    deps += [
109      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
110      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
111    ]
112  }
113  foreach(_platform, target_platform_list) {
114    deps += [ ":${_platform}_system_image" ]
115  }
116}
117
118group("userdata_image") {
119  deps = []
120  if (is_standard_system) {
121    deps += [
122      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
123      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
124    ]
125  }
126  foreach(_platform, target_platform_list) {
127    deps += [ ":${_platform}_userdata_image" ]
128  }
129}
130
131group("vendor_image") {
132  deps = []
133  if (is_standard_system) {
134    deps += [
135      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
136      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
137    ]
138  }
139  foreach(_platform, target_platform_list) {
140    deps += [ ":${_platform}_vendor_image" ]
141  }
142}
143
144group("ramdisk_image") {
145  deps = []
146  if (is_standard_system) {
147    deps += [
148      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
149      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
150    ]
151  }
152  foreach(_platform, target_platform_list) {
153    if (enable_ramdisk) {
154      deps += [ ":${_platform}_ramdisk_image" ]
155    }
156  }
157}
158
159group("updater_ramdisk_image") {
160  deps = []
161  if (is_standard_system) {
162    deps += [
163      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
164      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
165    ]
166  }
167  foreach(_platform, target_platform_list) {
168    deps += [ ":${_platform}_updater_ramdisk_image" ]
169  }
170}
171
172group("updater_image") {
173  deps = []
174  if (is_standard_system) {
175    deps += [
176      "//third_party/e2fsprogs:e2fsprogs_host_toolchain",
177      "//third_party/f2fs-tools:f2fs-tools_host_toolchain",
178    ]
179  }
180  foreach(_platform, target_platform_list) {
181    deps += [ ":${_platform}_updater_ramdisk_image" ]
182  }
183}
184
185build_image_tools_path = [
186  "//out/${device_name}/clang_x64/thirdparty/e2fsprogs",
187  "//out/${device_name}/clang_x64/thirdparty/f2fs-tools",
188  "//third_party/e2fsprogs/prebuilt/host/bin",
189  "//build/ohos/images/mkimage",
190]
191
192foreach(_platform, target_platform_list) {
193  current_platform = _platform
194  current_platform_dir = "${product_output_dir}/$current_platform"
195
196  system_module_info_list = "${current_platform_dir}/system_module_info.json"
197  system_modules_list = "${current_platform_dir}/system_modules_list.txt"
198
199  image_list = [
200    "system",
201    "vendor",
202    "userdata",
203    "sys_prod",
204    "chip_prod",
205    "updater_ramdisk",
206    "eng_system",
207    "eng_chipset",
208  ]
209  if (enable_ramdisk) {
210    image_list += [ "ramdisk" ]
211  }
212  foreach(_image_name, image_list) {
213    action_with_pydeps("${_platform}_${_image_name}_image") {
214      script = "//build/ohos/images/build_image.py"
215      depfile = "$target_gen_dir/$target_name.d"
216      deps = [ "//build/ohos/packages:${_platform}_install_modules" ]
217      if (!asan_detector) {
218        deps += [ "//build/ohos/packages:process_field_validate" ]
219        if (build_seccomp) {
220          deps += [ "//build/ohos/packages:check_seccomp_filter_name" ]
221        }
222      }
223
224      image_config_file =
225          "//build/ohos/images/mkimage/${_image_name}_image_conf.txt"
226      if (is_debug) {
227        image_config_file =
228            "//build/ohos/images/mkimage/debug/${_image_name}_image_conf.txt"
229      }
230      device_image_config_file =
231          "${product_output_dir}/imagesconf/${_image_name}_image_conf.txt"
232      if (_image_name == "ramdisk" || _image_name == "updater_ramdisk") {
233        output_image_file = "$root_build_dir/${_image_name}.img"
234      } else {
235        output_image_file = "$current_platform_dir/images/${_image_name}.img"
236      }
237      if (_image_name == "updater_ramdisk") {
238        image_input_path = "$current_platform_dir/updater"
239      } else {
240        image_input_path = "$current_platform_dir/${_image_name}"
241      }
242      if (_image_name == "userdata") {
243        image_input_path = "$current_platform_dir/data"
244      }
245
246      sources = [
247        image_config_file,
248        system_module_info_list,
249        system_modules_list,
250      ]
251      outputs = [ output_image_file ]
252      args = [
253        "--depfile",
254        rebase_path(depfile, root_build_dir),
255        "--image-name",
256        _image_name,
257        "--input-path",
258        rebase_path(image_input_path, root_build_dir),
259        "--image-config-file",
260        rebase_path(image_config_file, root_build_dir),
261        "--device-image-config-file",
262        rebase_path(device_image_config_file, root_build_dir),
263        "--output-image",
264        rebase_path(output_image_file, root_build_dir),
265        "--target-cpu",
266        target_cpu,
267        "--build-variant",
268        build_variant,
269        "--build-image-tools-path",
270      ]
271      args += rebase_path(build_image_tools_path, root_build_dir)
272      if (sparse_image) {
273        args += [ "--sparse-image" ]
274      }
275    }
276  }
277
278  # Used to generate chip_prod images of different products
279  foreach(_product, chip_product_list) {
280    _image_name = "chip_prod"
281    action_with_pydeps("${_platform}_${_product}_chip_prod_image") {
282      script = "//build/ohos/images/build_image.py"
283      depfile = "$target_gen_dir/$target_name.d"
284      deps = [ "//build/ohos/packages:${_platform}_install_modules" ]
285
286      image_config_file =
287          "//build/ohos/images/mkimage/${_image_name}_image_conf.txt"
288      device_image_config_file =
289          "${product_output_dir}/imagesconf/${_image_name}_image_conf.txt"
290      image_input_path = "${current_platform_dir}/${_image_name}/${_product}"
291      output_image_file =
292          "${current_platform_dir}/images/${_product}/${_image_name}.img"
293
294      sources = [
295        image_config_file,
296        system_module_info_list,
297        system_modules_list,
298      ]
299      outputs = [ output_image_file ]
300
301      args = [
302        "--depfile",
303        rebase_path(depfile, root_build_dir),
304        "--image-name",
305        _image_name,
306        "--input-path",
307        rebase_path(image_input_path, root_build_dir),
308        "--image-config-file",
309        rebase_path(image_config_file, root_build_dir),
310        "--device-image-config-file",
311        rebase_path(device_image_config_file, root_build_dir),
312        "--output-image",
313        rebase_path(output_image_file, root_build_dir),
314        "--target-cpu",
315        target_cpu,
316        "--build-image-tools-path",
317      ]
318      args += rebase_path(build_image_tools_path, root_build_dir)
319      if (sparse_image) {
320        args += [ "--sparse-image" ]
321      }
322    }
323  }
324}
325