# Copyright (C) 2022-2022 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("//build/ohos/ace/ace.gni")
import("../config.gni")

base_output_path = get_label_info(":query_syscap", "target_out_dir")
query_syscap_obj_path = base_output_path + "/query_syscap.o"

gen_js_obj("query_syscap_js") {
  input = "query_syscap.js"
  output = query_syscap_obj_path
}

sources_platform_common = [
  "../src/syscap_tool.c",
  "../src/create_pcid.c",
  "../src/endian_internal.c",
  "../src/context_tool.c",
  "../interfaces/inner_api/syscap_interface.c",
]

ohos_shared_library("systemcapability") {
  include_dirs = [
    "../src",
    "../interfaces/inner_api",
    "../include",
  ]
  include_dirs += [ syscap_codec_config_path ]

  sources = [ "napi_query_syscap.cpp" ]
  sources += sources_platform_common

  deps = [ ":query_syscap_js" ]
  external_deps = [
    "bounds_checking_function:libsec_static",
    "napi:ace_napi",
    "node:node_header_notice",
  ]

  if (syscap_codec_config_extern_path != "") {
    deps += [ "..:gen_syscap_define_custom" ]
    inputs = [ "${root_build_dir}/syscap_define_custom.h" ]
    include_dirs += [ "${root_build_dir}" ]
    cflags = [ "-DSYSCAP_DEFINE_EXTERN_ENABLE" ]
  }

  if (defined(ohos_lite)) {
    deps += [ "//build/lite/config/component/cJSON:cjson_static" ]
  } else {
    external_deps += [ "cJSON:cjson_static" ]
  }

  relative_install_dir = "module"
  subsystem_name = "developtools"
  part_name = "syscap_codec"
}