param_fixer.gni 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/config/python.gni")
import("//build/templates/common/copy.gni")

template("ohos_prebuilt_para") {
  assert(defined(invoker.source), "source must be defined for ${target_name}.")

  _fixed_param_target = "${target_name}_param_fixed"
  _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 26
  action_with_pydeps(_fixed_param_target) {
    deps = []
M
init  
Mupceet 已提交
27
    script = "//base/startup/init/services/etc/param/param_fixer.py"
28 29 30 31 32 33 34 35 36 37
    depfile = "${target_gen_dir}/${target_name}.d"
    args = [
      "--output",
      rebase_path(_fixed_param_file, root_build_dir),
      "--source-file",
      rebase_path(invoker.source, root_build_dir),
      "--depfile",
      rebase_path(depfile, root_build_dir),
    ]
    if (defined(invoker.extra_paras)) {
38 39 40 41 42 43
      foreach(extra, invoker.extra_paras) {
        args += [
          "--extra",
          extra,
        ]
      }
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    }
    inputs = [ invoker.source ]
    outputs = [ _fixed_param_file ]
  }

  ohos_copy(target_name) {
    deps = [ ":$_fixed_param_target" ]
    forward_variables_from(invoker,
                           [
                             "testonly",
                             "visibility",

                             "deps",
                             "public_configs",
                             "subsystem_name",
                             "part_name",

                             # For generate_module_info
                             "install_images",
                             "module_install_dir",
                             "relative_install_dir",
                             "symlink_target_name",

                             # Open source license related
                             "license_file",
                             "license_as_sources",
                           ])
    sources = [ _fixed_param_file ]
72
    outputs = [ "${target_out_dir}/${target_name}/${_output_para_file}" ]
73 74
    module_type = "etc"
    install_enable = true
75 76
    module_source_dir = "${target_out_dir}/${target_name}"
    module_install_name = _output_para_file
77 78 79 80 81
    if (defined(invoker.install_enable)) {
      install_enable = invoker.install_enable
    }
  }
}