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 ]) 64 65 shared_library("${target_name}") { 66 forward_variables_from(invoker, 67 "*", 68 [ 69 "configs", 70 "remove_configs", 71 "relative_install_dir", 72 "subsystem_name", 73 "install_enable", 74 "part_name", 75 ]) 76 77 if (defined(invoker.configs)) { 78 configs += invoker.configs 79 } 80 81 if (defined(invoker.remove_configs)) { 82 configs -= invoker.remove_configs 83 } 84 85 assert(!defined(invoker.output_dir), 86 "output_dir is not allowed to be defined.") 87 output_dir = "${root_out_dir}/lib" 88 } 89} 90 91template("ohos_static_library") { 92 not_needed(invoker, 93 [ 94 "part_name", 95 "external_deps", 96 "branch_protector_ret", 97 ]) 98 99 static_library("${target_name}") { 100 forward_variables_from(invoker, 101 "*", 102 [ 103 "configs", 104 "remove_configs", 105 "relative_install_dir", 106 "subsystem_name", 107 "install_enable", 108 ]) 109 110 if (defined(invoker.configs)) { 111 configs += invoker.configs 112 } 113 114 if (defined(invoker.remove_configs)) { 115 configs -= invoker.remove_configs 116 } 117 } 118} 119 120template("ohos_prebuilt_etc") { 121 copy("${target_name}") { 122 forward_variables_from(invoker, 123 "*", 124 [ 125 "subsystem_name", 126 "install_enable", 127 "source", 128 "module_install_dir", 129 "part_name", 130 ]) 131 sources = [ invoker.source ] 132 outputs = [ "${target_out_dir}/${invoker.source}" ] 133 } 134} 135 136template("ohos_source_set") { 137 not_needed(invoker, 138 [ 139 "public_external_deps", 140 "part_name", 141 "subsystem_name", 142 "external_deps", 143 ]) 144 145 source_set(target_name) { 146 forward_variables_from(invoker, 147 "*", 148 [ 149 "configs", 150 "public_configs", 151 "remove_configs", 152 ]) 153 if (defined(invoker.configs)) { 154 configs += invoker.configs 155 } 156 if (defined(invoker.public_configs)) { 157 configs += invoker.public_configs 158 } 159 if (defined(invoker.remove_configs)) { 160 configs -= invoker.remove_configs 161 } 162 } 163} 164