# 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/ohos.gni")
import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni")
import("$hdf_framework_path/tools/hc-gen/hc_gen.gni")

hc_gen("build_hcs") {
  hcs_source = "/hdf.hcs"

  if (product_company == "openharmony") {
    hcs_config_path = "default"
  } else {
    hcs_config_path = "//vendor/$product_company/$product_name/hdf_config/uhdf/"
  }
  sources = [ rebase_path(hcs_config_path + hcs_source) ]
  outputs = [ "$target_gen_dir/hdf_default.hcb" ]
}

ohos_prebuilt_etc("hdf_default.hcb") {
  deps = [ ":build_hcs" ]
  hcs_outputs = get_target_outputs(":build_hcs")
  source = hcs_outputs[0]
  relative_install_dir = "hdfconfig"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "hdf_core"
}

hc_gen_start_cfg("gen_start_cfg") {
  hcs_source = "/hdf.hcs"

  if (product_company == "openharmony") {
    hcs_config_path = "default"
  } else {
    hcs_config_path = "//vendor/$product_company/$product_name/hdf_config/uhdf/"
  }
  sources = [ rebase_path(hcs_config_path + hcs_source) ]
  outputs = [ "$target_gen_dir/hdf_devhost.cfg" ]
}

ohos_prebuilt_etc("hdf_devhost.cfg") {
  deps = [ ":gen_start_cfg" ]
  outputs = get_target_outputs(":gen_start_cfg")
  source = outputs[0]
  relative_install_dir = "init"
  install_images = [ chipset_base_dir ]
  subsystem_name = "hdf"
  part_name = "hdf_core"
}