1# Copyright (c) 2024 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 14lite_target_list = [] 15 16# Step 1: Read product configuration profile. 17product_cfg = read_file("${product_config_path}/config.json", "json") 18 19parts_targets_info = 20 read_file( 21 "${root_build_dir}/build_configs/parts_info/parts_modules_info.json", 22 "json") 23 24# Step 2: Loop subsystems configured by product. 25foreach(product_configed_subsystem, product_cfg.subsystems) { 26 subsystem_name = product_configed_subsystem.subsystem 27 28 if (build_xts || (!build_xts && subsystem_name != "xts")) { 29 # Step 3: Read OS subsystems profile. 30 subsystem_parts_info = { 31 } 32 subsystem_parts_info = read_file( 33 "${root_build_dir}/build_configs/mini_adapter/${subsystem_name}.json", 34 "json") 35 36 # Step 4: Loop components configured by product. 37 foreach(product_configed_component, product_configed_subsystem.components) { 38 # Step 5: Check whether the component configured by product is exist. 39 component_found = false 40 41 foreach(part_name, subsystem_parts_info.parts) { 42 if (product_configed_component.component == part_name) { 43 component_found = true 44 } 45 } 46 47 assert(component_found, 48 "Component \"${product_configed_component.component}\" not found" + 49 ", please check your product configuration.") 50 51 # Step 6: Loop OS components and check validity of product configuration. 52 foreach(part_name, subsystem_parts_info.parts) { 53 kernel_valid = true 54 55 # Step 6.1: Skip component which not configured by product. 56 if (part_name == product_configed_component.component) { 57 # Step 6.1.1: Loop OS components adapted kernel type. 58 59 assert( 60 kernel_valid, 61 "Invalid component configed, ${subsystem_name}:${product_configed_component.component} " + "not available for kernel: ${product_cfg.kernel_type}!") 62 63 # Step 6.1.2: Add valid component for compiling. 64 # Skip kernel target for userspace only scenario. 65 if (!ohos_build_userspace_only || 66 (ohos_build_userspace_only && subsystem_name != "kernel" && 67 subsystem_name != "vendor")) { 68 foreach(_p_info, parts_targets_info.parts) { 69 if (_p_info.part_name == product_configed_component.component) { 70 lite_target_list += _p_info.module_list 71 } 72 } 73 } 74 } 75 } 76 } 77 } 78} 79 80# Skip device target for userspace only scenario. 81if (!ohos_build_userspace_only) { 82 # Step 7: Add device and product target by default. 83 # liteos_m kernel organise device build targets, but not by default. 84 if (product_cfg.kernel_type != "liteos_m") { 85 lite_target_list += [ "${device_path}/../" ] 86 } 87} 88