15f9996aaSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd. 25f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 35f9996aaSopenharmony_ci# you may not use this file except in compliance with the License. 45f9996aaSopenharmony_ci# You may obtain a copy of the License at 55f9996aaSopenharmony_ci# 65f9996aaSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 75f9996aaSopenharmony_ci# 85f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software 95f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 105f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 115f9996aaSopenharmony_ci# See the License for the specific language governing permissions and 125f9996aaSopenharmony_ci# limitations under the License. 135f9996aaSopenharmony_ci 145f9996aaSopenharmony_ciimport("//build/config/python.gni") 155f9996aaSopenharmony_ciimport("//build/ohos/ebpf.gni") 165f9996aaSopenharmony_ciimport("//build/ohos_var.gni") 175f9996aaSopenharmony_ci 185f9996aaSopenharmony_citemplate("ohos_part") { 195f9996aaSopenharmony_ci assert(defined(invoker.subsystem_name), "module_list is required.") 205f9996aaSopenharmony_ci assert(defined(invoker.module_list), "module_list is required.") 215f9996aaSopenharmony_ci 225f9996aaSopenharmony_ci part_label = get_label_info(":${target_name}", "label_with_toolchain") 235f9996aaSopenharmony_ci _deps = [] 245f9996aaSopenharmony_ci foreach(module_label, invoker.module_list) { 255f9996aaSopenharmony_ci _deps += [ get_label_info(module_label, "label_with_toolchain") ] 265f9996aaSopenharmony_ci } 275f9996aaSopenharmony_ci 285f9996aaSopenharmony_ci # add sdk dep 295f9996aaSopenharmony_ci parts_targets_info_file = 305f9996aaSopenharmony_ci "${root_build_dir}/build_configs/required_parts_targets_list.json" 315f9996aaSopenharmony_ci 325f9996aaSopenharmony_ci parts_targets_info = read_file(parts_targets_info_file, "json") 335f9996aaSopenharmony_ci foreach(part_info, parts_targets_info) { 345f9996aaSopenharmony_ci if (part_info.part == part_label) { 355f9996aaSopenharmony_ci if (defined(part_info.inner_kits)) { 365f9996aaSopenharmony_ci _deps += [ part_info.inner_kits ] 375f9996aaSopenharmony_ci } 385f9996aaSopenharmony_ci } 395f9996aaSopenharmony_ci } 405f9996aaSopenharmony_ci 415f9996aaSopenharmony_ci part_name = target_name 425f9996aaSopenharmony_ci if (defined(invoker.origin_name)) { 435f9996aaSopenharmony_ci origin_part_name = invoker.origin_name 445f9996aaSopenharmony_ci } else { 455f9996aaSopenharmony_ci origin_part_name = part_name 465f9996aaSopenharmony_ci } 475f9996aaSopenharmony_ci if (defined(invoker.variant)) { 485f9996aaSopenharmony_ci variant_name = invoker.variant 495f9996aaSopenharmony_ci } else { 505f9996aaSopenharmony_ci variant_name = "phone" 515f9996aaSopenharmony_ci } 525f9996aaSopenharmony_ci 535f9996aaSopenharmony_ci part_modules_info_file = "${target_gen_dir}/${part_name}_modules.json" 545f9996aaSopenharmony_ci generated_file("${part_name}_info") { 555f9996aaSopenharmony_ci outputs = [ part_modules_info_file ] 565f9996aaSopenharmony_ci data_keys = [ "install_modules" ] 575f9996aaSopenharmony_ci output_conversion = "json" 585f9996aaSopenharmony_ci 595f9996aaSopenharmony_ci part_install_info = { 605f9996aaSopenharmony_ci part_label = part_label 615f9996aaSopenharmony_ci part_name = part_name 625f9996aaSopenharmony_ci origin_part_name = origin_part_name 635f9996aaSopenharmony_ci variant_name = variant_name 645f9996aaSopenharmony_ci subsystem_name = invoker.subsystem_name 655f9996aaSopenharmony_ci part_info_file = 665f9996aaSopenharmony_ci rebase_path(get_label_info(part_label, "target_out_dir"), 675f9996aaSopenharmony_ci root_build_dir) + "/${part_name}_install_modules.json" 685f9996aaSopenharmony_ci toolchain_label = get_label_info(part_label, "toolchain") 695f9996aaSopenharmony_ci build_out_dir = rebase_path(root_out_dir, root_build_dir) 705f9996aaSopenharmony_ci } 715f9996aaSopenharmony_ci 725f9996aaSopenharmony_ci part_host_info = { 735f9996aaSopenharmony_ci part_label = part_label 745f9996aaSopenharmony_ci part_name = part_name 755f9996aaSopenharmony_ci origin_part_name = origin_part_name 765f9996aaSopenharmony_ci variant_name = variant_name 775f9996aaSopenharmony_ci subsystem_name = invoker.subsystem_name 785f9996aaSopenharmony_ci 795f9996aaSopenharmony_ci # generated by generate_part_info.py 805f9996aaSopenharmony_ci part_info_file = 815f9996aaSopenharmony_ci rebase_path(get_label_info(part_label, "target_out_dir"), 825f9996aaSopenharmony_ci root_build_dir) + "/${part_name}_host_modules.json" 835f9996aaSopenharmony_ci toolchain_label = get_label_info(part_label, "toolchain") 845f9996aaSopenharmony_ci build_out_dir = rebase_path(root_out_dir, root_build_dir) 855f9996aaSopenharmony_ci } 865f9996aaSopenharmony_ci metadata = { 875f9996aaSopenharmony_ci part_installed_info = [ part_install_info ] 885f9996aaSopenharmony_ci part_host_info = [ part_host_info ] 895f9996aaSopenharmony_ci } 905f9996aaSopenharmony_ci deps = _deps 915f9996aaSopenharmony_ci } 925f9996aaSopenharmony_ci 935f9996aaSopenharmony_ci # ebpf 945f9996aaSopenharmony_ci if (ebpf_enable) { 955f9996aaSopenharmony_ci if (defined(invoker.ebpf_testcase)) { 965f9996aaSopenharmony_ci collect_ebpf_testcase("${part_name}_ebpf_testcase") { 975f9996aaSopenharmony_ci ebpf_testcase = invoker.ebpf_testcase 985f9996aaSopenharmony_ci } 995f9996aaSopenharmony_ci _deps += [ ":${part_name}_ebpf_testcase" ] 1005f9996aaSopenharmony_ci } 1015f9996aaSopenharmony_ci } 1025f9996aaSopenharmony_ci 1035f9996aaSopenharmony_ci part_install_modules_file = 1045f9996aaSopenharmony_ci "${target_out_dir}/${part_name}_install_modules.json" 1055f9996aaSopenharmony_ci part_dep_modules_file = "${target_out_dir}/${part_name}_dep_modules.json" 1065f9996aaSopenharmony_ci part_sdk_modules_info_file = 1075f9996aaSopenharmony_ci "${target_gen_dir}/${part_name}_sdk_install_modules.json" 1085f9996aaSopenharmony_ci part_host_modules_file = "${target_out_dir}/${part_name}_host_modules.json" 1095f9996aaSopenharmony_ci action_with_pydeps(target_name) { 1105f9996aaSopenharmony_ci deps = [ ":${part_name}_info" ] 1115f9996aaSopenharmony_ci script = "//build/ohos/generate_part_info.py" 1125f9996aaSopenharmony_ci sources = [ part_modules_info_file ] 1135f9996aaSopenharmony_ci outputs = [ 1145f9996aaSopenharmony_ci part_install_modules_file, 1155f9996aaSopenharmony_ci part_dep_modules_file, 1165f9996aaSopenharmony_ci ] 1175f9996aaSopenharmony_ci args = [ 1185f9996aaSopenharmony_ci "--part-name", 1195f9996aaSopenharmony_ci part_name, 1205f9996aaSopenharmony_ci "--origin-part-name", 1215f9996aaSopenharmony_ci origin_part_name, 1225f9996aaSopenharmony_ci "--input-file", 1235f9996aaSopenharmony_ci rebase_path(part_modules_info_file, root_build_dir), 1245f9996aaSopenharmony_ci "--sdk-modules-info-file", 1255f9996aaSopenharmony_ci rebase_path(part_sdk_modules_info_file, root_build_dir), 1265f9996aaSopenharmony_ci "--output-install-file", 1275f9996aaSopenharmony_ci rebase_path(part_install_modules_file, root_build_dir), 1285f9996aaSopenharmony_ci "--output-deps-file", 1295f9996aaSopenharmony_ci rebase_path(part_dep_modules_file, root_build_dir), 1305f9996aaSopenharmony_ci "--output-host-file", 1315f9996aaSopenharmony_ci rebase_path(part_host_modules_file, root_build_dir), 1325f9996aaSopenharmony_ci "--current-toolchain", 1335f9996aaSopenharmony_ci "${current_toolchain}", 1345f9996aaSopenharmony_ci "--host-toolchain", 1355f9996aaSopenharmony_ci "${host_toolchain}", 1365f9996aaSopenharmony_ci ] 1375f9996aaSopenharmony_ci } 1385f9996aaSopenharmony_ci} 139