1# Copyright (c) 2021 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("//build/config/python.gni") 15import("//build/templates/common/copy.gni") 16 17template("ohos_prebuilt_para") { 18 assert(defined(invoker.source), "source must be defined for ${target_name}.") 19 20 _fixed_param_target = "${target_name}_param_fixed" 21 _fixed_param_file = target_gen_dir + "/${target_name}.fixed/" + 22 get_path_info(invoker.source, "file") 23 24 _output_para_file = get_path_info(invoker.source, "file") 25 action_with_pydeps(_fixed_param_target) { 26 deps = [] 27 script = "//build/config/components/init/param/param_fixer.py" 28 depfile = "${target_gen_dir}/${target_name}.d" 29 args = [ 30 "--output", 31 rebase_path(_fixed_param_file, root_build_dir), 32 "--source-file", 33 rebase_path(invoker.source, root_build_dir), 34 "--depfile", 35 rebase_path(depfile, root_build_dir), 36 ] 37 if (defined(invoker.extra_paras)) { 38 foreach(extra, invoker.extra_paras) { 39 args += [ 40 "--extra", 41 extra, 42 ] 43 } 44 } 45 inputs = [ invoker.source ] 46 outputs = [ _fixed_param_file ] 47 } 48 49 ohos_copy(target_name) { 50 deps = [ ":$_fixed_param_target" ] 51 forward_variables_from(invoker, 52 [ 53 "testonly", 54 "visibility", 55 56 "deps", 57 "public_configs", 58 "subsystem_name", 59 "part_name", 60 61 # For generate_module_info 62 "install_images", 63 "module_install_dir", 64 "relative_install_dir", 65 "symlink_target_name", 66 67 # Open source license related 68 "license_file", 69 "license_as_sources", 70 ]) 71 sources = [ _fixed_param_file ] 72 outputs = [ "${target_out_dir}/${target_name}/${_output_para_file}" ] 73 module_type = "etc" 74 install_enable = true 75 module_source_dir = "${target_out_dir}/${target_name}" 76 module_install_name = _output_para_file 77 if (defined(invoker.install_enable)) { 78 install_enable = invoker.install_enable 79 } 80 } 81} 82