• 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/ebpf.gni")
16import("//build/ohos_var.gni")
17
18template("ohos_part") {
19  assert(defined(invoker.subsystem_name), "module_list is required.")
20  assert(defined(invoker.module_list), "module_list is required.")
21
22  part_label = get_label_info(":${target_name}", "label_with_toolchain")
23  _deps = []
24  foreach(module_label, invoker.module_list) {
25    _deps += [ get_label_info(module_label, "label_with_toolchain") ]
26  }
27
28  # add sdk dep
29  parts_targets_info_file =
30      "${root_build_dir}/build_configs/required_parts_targets_list.json"
31
32  parts_targets_info = read_file(parts_targets_info_file, "json")
33  foreach(part_info, parts_targets_info) {
34    if (part_info.part == part_label) {
35      if (defined(part_info.inner_kits)) {
36        _deps += [ part_info.inner_kits ]
37      }
38    }
39  }
40
41  part_name = target_name
42  if (defined(invoker.origin_name)) {
43    origin_part_name = invoker.origin_name
44  } else {
45    origin_part_name = part_name
46  }
47  if (defined(invoker.variant)) {
48    variant_name = invoker.variant
49  } else {
50    variant_name = "phone"
51  }
52
53  part_modules_info_file = "${target_gen_dir}/${part_name}_modules.json"
54  generated_file("${part_name}_info") {
55    outputs = [ part_modules_info_file ]
56    data_keys = [ "install_modules" ]
57    output_conversion = "json"
58
59    part_install_info = {
60      part_label = part_label
61      part_name = part_name
62      origin_part_name = origin_part_name
63      variant_name = variant_name
64      subsystem_name = invoker.subsystem_name
65      part_info_file =
66          rebase_path(get_label_info(part_label, "target_out_dir"),
67                      root_build_dir) + "/${part_name}_install_modules.json"
68      toolchain_label = get_label_info(part_label, "toolchain")
69      build_out_dir = rebase_path(root_out_dir, root_build_dir)
70    }
71    metadata = {
72      part_installed_info = [ part_install_info ]
73    }
74    deps = _deps
75  }
76
77  # ebpf
78  if (ebpf_enable) {
79    if (defined(invoker.ebpf_testcase)) {
80      collect_ebpf_testcase("${part_name}_ebpf_testcase") {
81        ebpf_testcase = invoker.ebpf_testcase
82      }
83      _deps += [ ":${part_name}_ebpf_testcase" ]
84    }
85  }
86
87  part_install_modules_file =
88      "${target_out_dir}/${part_name}_install_modules.json"
89  part_dep_modules_file = "${target_out_dir}/${part_name}_dep_modules.json"
90  part_sdk_modules_info_file =
91      "${target_gen_dir}/${part_name}_sdk_install_modules.json"
92
93  action_with_pydeps(target_name) {
94    deps = [ ":${part_name}_info" ]
95    script = "//build/ohos/generate_part_info.py"
96    sources = [ part_modules_info_file ]
97    outputs = [
98      part_install_modules_file,
99      part_dep_modules_file,
100    ]
101    args = [
102      "--part-name",
103      part_name,
104      "--origin-part-name",
105      origin_part_name,
106      "--input-file",
107      rebase_path(part_modules_info_file, root_build_dir),
108      "--sdk-modules-info-file",
109      rebase_path(part_sdk_modules_info_file, root_build_dir),
110      "--output-install-file",
111      rebase_path(part_install_modules_file, root_build_dir),
112      "--output-deps-file",
113      rebase_path(part_dep_modules_file, root_build_dir),
114      "--current-toolchain",
115      "${current_toolchain}",
116    ]
117  }
118}
119