1# Copyright (c) 2020 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. 13import("//build/lite/ndk/ndk.gni") 14 15# gn version >= 1714 required. 16assert(gn_version >= 1714, "GN version 1714 required, please upgrade!") 17 18# write version info. 19version_info = [ 20 "VERSION=\"$ohos_version\"", 21 "BUILD_TIME=\"$ohos_build_datetime\"", 22] 23write_file("$root_build_dir/etc/version-info", version_info) 24 25group("prebuilts") { 26 public_deps = [ "//prebuilts/lite/sysroot" ] 27} 28 29group("ohos") { 30 deps = [] 31 if (ohos_build_target == "") { 32 # Step 1: Read product configuration profile. 33 product_cfg = read_file("${product_path}/config.json", "json") 34 35 parts_targets_info = read_file( 36 "//out/${device_name}/${product_name}/build_configs/parts_info/parts_modules_info.json", 37 "json") 38 39 # Step 2: Loop subsystems configured by product. 40 foreach(product_configed_subsystem, product_cfg.subsystems) { 41 subsystem_name = product_configed_subsystem.subsystem 42 43 if (build_xts || (!build_xts && subsystem_name != "xts")) { 44 # Step 3: Read OS subsystems profile. 45 subsystem_parts_info = { 46 } 47 subsystem_parts_info = read_file( 48 "//out/${device_name}/${product_name}/build_configs/mini_adapter/${subsystem_name}.json", 49 "json") 50 51 # Step 4: Loop components configured by product. 52 foreach(product_configed_component, 53 product_configed_subsystem.components) { 54 # Step 5: Check whether the component configured by product is exist. 55 component_found = false 56 57 foreach(part_name, subsystem_parts_info.parts) { 58 if (product_configed_component.component == part_name) { 59 component_found = true 60 } 61 } 62 63 assert( 64 component_found, 65 "Component \"${product_configed_component.component}\" not found" + ", please check your product configuration.") 66 67 # Step 6: Loop OS components and check validity of product configuration. 68 foreach(part_name, subsystem_parts_info.parts) { 69 kernel_valid = true 70 board_valid = false 71 72 # Step 6.1: Skip component which not configured by product. 73 if (part_name == product_configed_component.component) { 74 # Step 6.1.1: Loop OS components adapted kernel type. 75 76 assert( 77 kernel_valid, 78 "Invalid component configed, ${subsystem_name}:${product_configed_component.component} " + "not available for kernel: ${product_cfg.kernel_type}!") 79 80 # Step 6.1.2: Add valid component for compiling. 81 # Skip kernel target for userspace only scenario. 82 if (!ohos_build_userspace_only || 83 (ohos_build_userspace_only && subsystem_name != "kernel" && 84 subsystem_name != "vendor")) { 85 foreach(_p_info, parts_targets_info.parts) { 86 if (_p_info.part_name == 87 product_configed_component.component) { 88 foreach(component_target, _p_info.module_list) { 89 if (product_configed_component.component == "liteos_m") { 90 if (component_target != 91 "//kernel/liteos_m:build_kernel_image") { 92 deps += [ component_target ] 93 } 94 } else { 95 deps += [ component_target ] 96 } 97 } 98 } 99 } 100 } 101 } 102 } 103 } 104 } 105 } 106 107 # Skip device target for userspace only scenario. 108 if (!ohos_build_userspace_only) { 109 # Step 7: Add device and product target by default. 110 # liteos_m kernel organise device build targets, but not by default. 111 if (product_cfg.kernel_type != "liteos_m") { 112 deps += [ "${device_path}/../" ] 113 } 114 } 115 } else { 116 deps += string_split(ohos_build_target, "&&") 117 } 118} 119 120group("product") { 121 deps = [] 122 123 # build product, skip build single component scenario. 124 if (ohos_build_target == "") { 125 deps += [ "${product_path}" ] 126 } 127} 128 129group("ndk") { 130 # Add native API targets. 131 deps = [] 132 if (ohos_build_ndk) { 133 deps += [ "//build/lite/ndk:ndk" ] 134 } 135} 136 137if (ohos_build_type == "debug" && product != "") { 138 action("gen_testfwk_info") { 139 outputs = [ "$root_out_dir/gen_testfwk_info.log" ] 140 script = "//build/lite/testfwk/gen_testfwk_info.py" 141 archive_dir_name = "test_info" 142 args = [ 143 "--component-info-file", 144 rebase_path("${product_path}/config.json"), 145 "--output-json-fold", 146 rebase_path("${root_out_dir}/${archive_dir_name}/build_configs/"), 147 "--output-json-file-name", 148 "infos_for_testfwk.json", 149 "--output-module-list-files-fold", 150 rebase_path("${root_out_dir}/${archive_dir_name}/module_list_files/"), 151 ] 152 } 153} 154