884d65c2创建于 2025年2月21日历史提交
# Copyright (c) 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("./../../../miscdevice.gni")

ohos_ndk_library("liblight_ndk") {
  output_name = "light_agent"
  ndk_description_file = "./liblight.json"
  min_compact_version = "7"
}

ohos_ndk_headers("light_ndk_header") {
  dest_dir = "$ndk_headers_out_dir/sensors"
  sources = [
    "$SUBSYSTEM_DIR/interfaces/inner_api/light/light_agent.h",
    "$SUBSYSTEM_DIR/interfaces/inner_api/light/light_agent_type.h",
  ]
}

config("light_config") {
  include_dirs = [ "$SUBSYSTEM_DIR/interfaces/inner_api/light" ]
}

ohos_shared_library("light_interface_native") {
  output_name = "light_agent"
  sources = [ "light_agent.cpp" ]

  include_dirs = [
    "$SUBSYSTEM_DIR/interfaces/inner_api/light",
    "$SUBSYSTEM_DIR/utils/common/include",
    "include",
  ]

  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  cflags = [ "-Wno-error=inconsistent-missing-override" ]

  deps = [
    "$SUBSYSTEM_DIR/frameworks/native/light:liblight_native",
    "$SUBSYSTEM_DIR/frameworks/native/light:liblight_ndk",
    "$SUBSYSTEM_DIR/frameworks/native/light:light_ndk_header",
    "$SUBSYSTEM_DIR/frameworks/native/vibrator:miscdevice_service_file_h",
  ]

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

  public_configs = [ ":light_config" ]
  innerapi_tags = [ "platformsdk" ]
  part_name = "miscdevice"
  subsystem_name = "sensors"
}

ohos_shared_library("liblight_native") {
  sources = [ "src/light_client.cpp" ]

  include_dirs = [
    "include",
    "$SUBSYSTEM_DIR/interfaces/inner_api/light",
    "$SUBSYSTEM_DIR/utils/common/include",
  ]

  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }

  cflags = [ "-fstack-protector-all" ]

  deps = [
    "$SUBSYSTEM_DIR/frameworks/native/light:light_ndk_header",
    "$SUBSYSTEM_DIR/frameworks/native/vibrator:miscdevice_service_proxy",
    "$SUBSYSTEM_DIR/utils/common:libmiscdevice_utils",
  ]

  external_deps = [
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  if (miscdevice_feature_hiviewdfx_hisysevent) {
    external_deps += [ "hisysevent:libhisysevent" ]
  }

  defines = miscdevice_default_defines

  innerapi_tags = [ "platformsdk_indirect" ]
  part_name = "miscdevice"
  subsystem_name = "sensors"
}

group("light_target") {
  deps = [
    ":liblight_native",
    ":light_interface_native",
  ]
}