1# Copyright (c) 2021-2022 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("ohos-var.gni") 15 16template("ohos_executable") { 17 not_needed(invoker, 18 [ 19 "install_images", 20 "part_name", 21 "external_deps", 22 ]) 23 24 executable("${target_name}") { 25 forward_variables_from(invoker, 26 "*", 27 [ 28 "configs", 29 "remove_configs", 30 "public_configs", 31 "relative_install_dir", 32 "subsystem_name", 33 "install_enable", 34 ]) 35 if (defined(invoker.configs)) { 36 configs += invoker.configs 37 } 38 39 if (defined(invoker.public_configs)) { 40 configs += invoker.public_configs 41 } 42 if (defined(invoker.remove_configs)) { 43 configs -= invoker.remove_configs 44 } 45 46 assert(!defined(invoker.output_dir), 47 "output_dir is not allowed to be defined.") 48 output_dir = "${root_out_dir}/bin" 49 } 50} 51 52template("ohos_shared_library") { 53 not_needed(invoker, 54 [ 55 "install_images", 56 "part_name", 57 "external_deps", 58 "innerapi_tags", 59 "branch_protector_ret", 60 "subsystem_name", 61 "relative_install_dir", 62 "install_enable", 63 "stack_protector_ret", 64 ]) 65 66 shared_library("${target_name}") { 67 forward_variables_from(invoker, 68 "*", 69 [ 70 "configs", 71 "remove_configs", 72 "relative_install_dir", 73 "subsystem_name", 74 "install_enable", 75 "part_name", 76 ]) 77 78 if (defined(invoker.configs)) { 79 configs += invoker.configs 80 } 81 82 if (defined(invoker.remove_configs)) { 83 configs -= invoker.remove_configs 84 } 85 86 assert(!defined(invoker.output_dir), 87 "output_dir is not allowed to be defined.") 88 output_dir = "${root_out_dir}/lib" 89 } 90} 91 92template("ohos_static_library") { 93 not_needed(invoker, 94 [ 95 "part_name", 96 "external_deps", 97 "branch_protector_ret", 98 "stack_protector_ret", 99 ]) 100 101 static_library("${target_name}") { 102 forward_variables_from(invoker, 103 "*", 104 [ 105 "configs", 106 "remove_configs", 107 "relative_install_dir", 108 "subsystem_name", 109 "install_enable", 110 ]) 111 112 if (defined(invoker.configs)) { 113 configs += invoker.configs 114 } 115 116 if (defined(invoker.remove_configs)) { 117 configs -= invoker.remove_configs 118 } 119 } 120} 121 122template("ohos_prebuilt_etc") { 123 copy("${target_name}") { 124 forward_variables_from(invoker, 125 "*", 126 [ 127 "subsystem_name", 128 "install_enable", 129 "source", 130 "module_install_dir", 131 "part_name", 132 ]) 133 sources = [ invoker.source ] 134 outputs = [ "${target_out_dir}/${invoker.source}" ] 135 } 136} 137 138template("ohos_source_set") { 139 not_needed(invoker, 140 [ 141 "public_external_deps", 142 "part_name", 143 "subsystem_name", 144 "external_deps", 145 ]) 146 147 source_set(target_name) { 148 forward_variables_from(invoker, 149 "*", 150 [ 151 "configs", 152 "public_configs", 153 "remove_configs", 154 ]) 155 if (defined(invoker.configs)) { 156 configs += invoker.configs 157 } 158 if (defined(invoker.public_configs)) { 159 configs += invoker.public_configs 160 } 161 if (defined(invoker.remove_configs)) { 162 configs -= invoker.remove_configs 163 } 164 } 165} 166