# 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")

template("kits_check_remove") {
  assert(defined(invoker.subsystem_name), "subsystem_name in required.")
  assert(defined(invoker.sdk_libs_name), "sdk_libs in required.")
  assert(defined(invoker.sign_file_root_dir), "sign_file_root_dir in required.")
  assert(defined(invoker.output_file), "output_file in required.")

  _deps = []
  if (defined(invoker.deps)) {
    _deps += invoker.deps
  }

  action_with_pydeps(target_name) {
    script = "//build/ohos/kits/kits_check_remove.py"
    deps = _deps

    outputs = [ invoker.output_file ]

    sdk_type = "java"
    if (defined(invoker.sdk_type)) {
      sdk_type = invoker.sdk_type
    }

    args = [
      "--subsystem-name",
      invoker.subsystem_name,
      "--sign-file-root-dir",
      rebase_path(invoker.sign_file_root_dir, root_build_dir),
      "--output-file",
      rebase_path(invoker.output_file, root_build_dir),
      "--kit-type",
      sdk_type,
    ]

    if (invoker.sdk_libs_name != []) {
      args += [ "--kit-list" ]
      foreach(sdk_lib_name, invoker.sdk_libs_name) {
        args += [ sdk_lib_name ]
      }
    }
  }
}