15f9996aaSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
25f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
35f9996aaSopenharmony_ci# you may not use this file except in compliance with the License.
45f9996aaSopenharmony_ci# You may obtain a copy of the License at
55f9996aaSopenharmony_ci#
65f9996aaSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
75f9996aaSopenharmony_ci#
85f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
95f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
105f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115f9996aaSopenharmony_ci# See the License for the specific language governing permissions and
125f9996aaSopenharmony_ci# limitations under the License.
135f9996aaSopenharmony_ci
145f9996aaSopenharmony_ciimport("//build/config/python.gni")
155f9996aaSopenharmony_ciimport("//build/templates/common/copy.gni")
165f9996aaSopenharmony_ci
175f9996aaSopenharmony_citemplate("ohos_prebuilt_para") {
185f9996aaSopenharmony_ci  assert(defined(invoker.source), "source must be defined for ${target_name}.")
195f9996aaSopenharmony_ci
205f9996aaSopenharmony_ci  _fixed_param_target = "${target_name}_param_fixed"
215f9996aaSopenharmony_ci  _fixed_param_file = target_gen_dir + "/${target_name}.fixed/" +
225f9996aaSopenharmony_ci                      get_path_info(invoker.source, "file")
235f9996aaSopenharmony_ci
245f9996aaSopenharmony_ci  _output_para_file = get_path_info(invoker.source, "file")
255f9996aaSopenharmony_ci  action_with_pydeps(_fixed_param_target) {
265f9996aaSopenharmony_ci    deps = []
275f9996aaSopenharmony_ci    script = "//build/config/components/init/param/param_fixer.py"
285f9996aaSopenharmony_ci    depfile = "${target_gen_dir}/${target_name}.d"
295f9996aaSopenharmony_ci    args = [
305f9996aaSopenharmony_ci      "--output",
315f9996aaSopenharmony_ci      rebase_path(_fixed_param_file, root_build_dir),
325f9996aaSopenharmony_ci      "--source-file",
335f9996aaSopenharmony_ci      rebase_path(invoker.source, root_build_dir),
345f9996aaSopenharmony_ci      "--depfile",
355f9996aaSopenharmony_ci      rebase_path(depfile, root_build_dir),
365f9996aaSopenharmony_ci    ]
375f9996aaSopenharmony_ci    if (defined(invoker.extra_paras)) {
385f9996aaSopenharmony_ci      foreach(extra, invoker.extra_paras) {
395f9996aaSopenharmony_ci        args += [
405f9996aaSopenharmony_ci          "--extra",
415f9996aaSopenharmony_ci          extra,
425f9996aaSopenharmony_ci        ]
435f9996aaSopenharmony_ci      }
445f9996aaSopenharmony_ci    }
455f9996aaSopenharmony_ci    inputs = [ invoker.source ]
465f9996aaSopenharmony_ci    outputs = [ _fixed_param_file ]
475f9996aaSopenharmony_ci  }
485f9996aaSopenharmony_ci
495f9996aaSopenharmony_ci  ohos_copy(target_name) {
505f9996aaSopenharmony_ci    deps = [ ":$_fixed_param_target" ]
515f9996aaSopenharmony_ci    forward_variables_from(invoker,
525f9996aaSopenharmony_ci                           [
535f9996aaSopenharmony_ci                             "testonly",
545f9996aaSopenharmony_ci                             "visibility",
555f9996aaSopenharmony_ci
565f9996aaSopenharmony_ci                             "deps",
575f9996aaSopenharmony_ci                             "public_configs",
585f9996aaSopenharmony_ci                             "subsystem_name",
595f9996aaSopenharmony_ci                             "part_name",
605f9996aaSopenharmony_ci
615f9996aaSopenharmony_ci                             # For generate_module_info
625f9996aaSopenharmony_ci                             "install_images",
635f9996aaSopenharmony_ci                             "module_install_dir",
645f9996aaSopenharmony_ci                             "relative_install_dir",
655f9996aaSopenharmony_ci                             "symlink_target_name",
665f9996aaSopenharmony_ci
675f9996aaSopenharmony_ci                             # Open source license related
685f9996aaSopenharmony_ci                             "license_file",
695f9996aaSopenharmony_ci                             "license_as_sources",
705f9996aaSopenharmony_ci                           ])
715f9996aaSopenharmony_ci    sources = [ _fixed_param_file ]
725f9996aaSopenharmony_ci    outputs = [ "${target_out_dir}/${target_name}/${_output_para_file}" ]
735f9996aaSopenharmony_ci    module_type = "etc"
745f9996aaSopenharmony_ci    install_enable = true
755f9996aaSopenharmony_ci    module_source_dir = "${target_out_dir}/${target_name}"
765f9996aaSopenharmony_ci    module_install_name = _output_para_file
775f9996aaSopenharmony_ci    if (defined(invoker.install_enable)) {
785f9996aaSopenharmony_ci      install_enable = invoker.install_enable
795f9996aaSopenharmony_ci    }
805f9996aaSopenharmony_ci  }
815f9996aaSopenharmony_ci}
82