# Copyright (c) 2023-2024 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")

sec_comp_root_dir = ".."

config("security_component_framework_src_set_config") {
  include_dirs = [
    "common/include",
    "${sec_comp_root_dir}/frameworks/inner_api/security_component/include",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component_common",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component/include",
  ]
}

ohos_source_set("security_component_framework_src_set") {
  subsystem_name = "security"
  part_name = "security_component_manager"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  branch_protector_ret = "pac_ret"
  include_dirs = [
    "common/include",
    "security_component/include",
  ]

  sources = [
    "common/src/sec_comp_tool.cpp",
    "security_component/src/location_button.cpp",
    "security_component/src/paste_button.cpp",
    "security_component/src/save_button.cpp",
    "security_component/src/sec_comp_base.cpp",
    "security_component/src/sec_comp_click_event_parcel.cpp",
  ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_framework_src_set_config" ]

  external_deps = [
    "access_token:libtokenid_sdk",
    "bounds_checking_function:libsec_shared",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
  ]
}

config("security_component_enhance_adapter_src_set_config") {
  include_dirs = [
    "common/include",
    "enhance_adapter/include",
    "${sec_comp_root_dir}/frameworks/inner_api/security_component/include",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component_common",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component/include",
  ]
}

ohos_source_set("security_component_enhance_adapter_src_set") {
  subsystem_name = "security"
  part_name = "security_component_manager"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  branch_protector_ret = "pac_ret"
  include_dirs = [ "common/include" ]

  sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_enhance_adapter_src_set_config" ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
  ]
}

ohos_source_set("security_component_enhance_adapter_service_src_set") {
  subsystem_name = "security"
  part_name = "security_component_manager"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  branch_protector_ret = "pac_ret"
  include_dirs = [ "common/include" ]

  sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_enhance_adapter_src_set_config" ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
    "-DSEC_COMP_SERVICE_COMPILE_ENABLE",
  ]
}

ohos_source_set("security_component_no_cfi_framework_src_set") {
  branch_protector_ret = "pac_ret"
  subsystem_name = "security"
  part_name = "security_component_manager"
  include_dirs = [
    "common/include",
    "security_component/include",
    "${sec_comp_root_dir}/frameworks/inner_api/security_component/include",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component/include",
  ]

  sources = [
    "common/src/sec_comp_tool.cpp",
    "security_component/src/location_button.cpp",
    "security_component/src/paste_button.cpp",
    "security_component/src/save_button.cpp",
    "security_component/src/sec_comp_base.cpp",
    "security_component/src/sec_comp_click_event_parcel.cpp",
  ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_framework_src_set_config" ]

  external_deps = [
    "access_token:libtokenid_sdk",
    "bounds_checking_function:libsec_shared",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
  ]
}

ohos_source_set("security_component_no_cfi_enhance_adapter_src_set") {
  branch_protector_ret = "pac_ret"
  subsystem_name = "security"
  part_name = "security_component_manager"
  include_dirs = [
    "common/include",
    "enhance_adapter/include",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component_common",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component/include",
    "${sec_comp_root_dir}/frameworks/inner_api/security_component/include",
  ]

  sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_enhance_adapter_src_set_config" ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
  ]
}

ohos_source_set("security_component_no_cfi_disable_enhance_adapter_src_set") {
  branch_protector_ret = "pac_ret"
  subsystem_name = "security"
  part_name = "security_component_manager"
  include_dirs = [
    "common/include",
    "enhance_adapter/include",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component_common",
    "${sec_comp_root_dir}/interfaces/inner_api/security_component/include",
    "${sec_comp_root_dir}/frameworks/inner_api/security_component/include",
  ]

  sources = [ "enhance_adapter/src/sec_comp_enhance_adapter.cpp" ]

  configs = [ "${sec_comp_root_dir}/config:coverage_flags" ]
  public_configs = [ ":security_component_enhance_adapter_src_set_config" ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "json:nlohmann_json_static",
  ]

  cflags_cc = [
    "-DHILOG_ENABLE",
    "-fvisibility=hidden",
    "-DSECURITY_COMPONENT_ENHANCE_DISABLE"
  ]
}