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 = [ "//third_party/musl:sysroot_lite" ] 27} 28 29group("ohos") { 30 deps = [] 31 if (ohos_build_target == "") { 32 # Step 1: Read product configuration profile. 33 product_cfg = read_file("${product_config_path}/config.json", "json") 34 35 parts_targets_info = read_file( 36 "${root_build_dir}/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 "${root_build_dir}/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 71 # Step 6.1: Skip component which not configured by product. 72 if (part_name == product_configed_component.component) { 73 # Step 6.1.1: Loop OS components adapted kernel type. 74 75 assert( 76 kernel_valid, 77 "Invalid component configed, ${subsystem_name}:${product_configed_component.component} " + "not available for kernel: ${product_cfg.kernel_type}!") 78 79 # Step 6.1.2: Add valid component for compiling. 80 # Skip kernel target for userspace only scenario. 81 if (!ohos_build_userspace_only || 82 (ohos_build_userspace_only && subsystem_name != "kernel" && 83 subsystem_name != "vendor")) { 84 foreach(_p_info, parts_targets_info.parts) { 85 if (_p_info.part_name == 86 product_configed_component.component) { 87 foreach(component_target, _p_info.module_list) { 88 if (product_configed_component.component == "liteos_m") { 89 if (component_target != 90 "//kernel/liteos_m:build_kernel_image") { 91 deps += [ component_target ] 92 } 93 } else if (product_configed_component.component == 94 "uniproton") { 95 if (component_target != 96 "//kernel/uniproton:build_kernel_image") { 97 deps += [ component_target ] 98 } 99 } else { 100 deps += [ component_target ] 101 } 102 } 103 } 104 } 105 } 106 } 107 } 108 } 109 } 110 } 111 112 # Skip device target for userspace only scenario. 113 if (!ohos_build_userspace_only) { 114 # Step 7: Add device and product target by default. 115 # liteos_m kernel organise device build targets, but not by default. 116 if (product_cfg.kernel_type != "liteos_m") { 117 deps += [ "${device_path}/../" ] 118 } 119 } 120 } else { 121 deps += string_split(ohos_build_target, "&&") 122 } 123} 124 125group("product") { 126 deps = [] 127 128 # build product, skip build single component scenario. 129 if (ohos_build_target == "") { 130 deps += [ "${product_path}" ] 131 } 132} 133 134group("ndk") { 135 # Add native API targets. 136 deps = [] 137 if (ohos_build_ndk) { 138 deps += [ "//build/lite/ndk:ndk" ] 139 } 140} 141 142if (ohos_build_type == "debug" && product != "") { 143 action("gen_testfwk_info") { 144 outputs = [ "$root_out_dir/gen_testfwk_info.log" ] 145 script = "//build/lite/testfwk/gen_testfwk_info.py" 146 archive_dir_name = "test_info" 147 args = [ 148 "--component-info-file", 149 rebase_path("${product_path}/config.json"), 150 "--output-json-fold", 151 rebase_path("${root_out_dir}/${archive_dir_name}/build_configs/"), 152 "--output-json-file-name", 153 "infos_for_testfwk.json", 154 "--output-module-list-files-fold", 155 rebase_path("${root_out_dir}/${archive_dir_name}/module_list_files/"), 156 ] 157 } 158} 159