f13e44a7创建于 2025年11月26日历史提交
# Copyright (c) 2022-2025 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/components/idl_tool/idl.gni")
import("//build/ohos.gni")
import("//foundation/resourceschedule/background_task_mgr/bgtaskmgr.gni")

idl_gen_interface("background_task_mgr_interface") {
  src_idl = rebase_path("IBackgroundTaskMgr.idl")
}

idl_gen_interface("background_task_subscriber_interface") {
  src_idl = rebase_path("IBackgroundTaskSubscriber.idl")
}

idl_gen_interface("expired_callback_interface") {
  src_idl = rebase_path("IExpiredCallback.idl")
}

config("bgtaskmgr_innerkits_public_config") {
  include_dirs = [
    "include",
    "${target_gen_dir}",
    "${bgtaskmgr_frameworks_path}/common/include",
    "${bgtaskmgr_frameworks_path}/include",
  ]
}

ohos_shared_library("bgtaskmgr_innerkits") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  cflags_cc = [
    "-fdata-sections",
    "-ffunction-sections",
    "-fstack-protector-strong",
    "-Os",
  ]
  deps = [
    ":background_task_mgr_interface",
    ":background_task_subscriber_interface",
    ":expired_callback_interface",
  ]

  sources = [
    "${bgtaskmgr_frameworks_path}/src/background_task_manager.cpp",
    "src/background_mode.cpp",
    "src/background_sub_mode.cpp",
    "src/background_task_mgr_helper.cpp",
    "src/background_task_subscriber.cpp",
    "src/continuous_task_callback_info.cpp",
    "src/continuous_task_info.cpp",
    "src/background_task_mode.cpp",
    "src/continuous_task_param.cpp",
    "src/continuous_task_request.cpp",
    "src/background_task_state_info.cpp",
    "src/background_task_submode.cpp",
    "src/continuous_task_suspend_reason.cpp",
    "src/delay_suspend_info.cpp",
    "src/efficiency_resource_info.cpp",
    "src/expired_callback.cpp",
    "src/resource_callback_info.cpp",
    "src/resource_type.cpp",
    "src/transient_task_app_info.cpp",
    "src/efficiency_resources_cpu_level.cpp",
  ]

  output_values = get_target_outputs(":background_task_mgr_interface")
  sources += filter_include(output_values,
                            [
                              "*_proxy.cpp",
                              "*_stub.cpp",
                            ])

  subscriber_output_values =
      get_target_outputs(":background_task_subscriber_interface")
  sources += filter_include(subscriber_output_values,
                            [
                              "*_proxy.cpp",
                              "*_stub.cpp",
                            ])

  expired_callback_output_values =
      get_target_outputs(":expired_callback_interface")
  sources += filter_include(expired_callback_output_values,
                            [
                              "*_proxy.cpp",
                              "*_stub.cpp",
                            ])

  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]

  external_deps = [
    "ability_base:configuration",
    "ability_runtime:wantagent_innerkits",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "common_event_service:cesfwk_innerkits",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  innerapi_tags = [ "platformsdk" ]
  version_script = "libbgtaskmgr_innerkits.versionscript"
}

ohos_source_set("background_task_mgr_stub") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":background_task_mgr_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [
    ":background_task_mgr_interface",
    ":expired_callback_interface",
  ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_base:configuration",
    "ability_runtime:wantagent_innerkits",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}

ohos_source_set("background_task_mgr_proxy") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":background_task_mgr_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [
    ":background_task_mgr_interface",
    ":expired_callback_interface",
  ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_base:configuration",
    "ability_runtime:wantagent_innerkits",
    "bundle_framework:appexecfwk_base",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}

ohos_source_set("background_task_subscriber_stub") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":background_task_subscriber_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [ ":background_task_subscriber_interface" ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_base:configuration",
    "ability_runtime:wantagent_innerkits",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}

ohos_source_set("background_task_subscriber_proxy") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":background_task_subscriber_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [ ":background_task_subscriber_interface" ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_runtime:wantagent_innerkits",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}

ohos_source_set("expired_callback_stub") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":expired_callback_interface")
  sources = filter_include(output_values, [ "*_stub.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [ ":expired_callback_interface" ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_runtime:wantagent_innerkits",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}

ohos_source_set("expired_callback_proxy") {
  branch_protector_ret = "pac_ret"
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    debug = false
  }
  output_values = get_target_outputs(":expired_callback_interface")
  sources = filter_include(output_values, [ "*_proxy.cpp" ])
  public_configs = [ ":bgtaskmgr_innerkits_public_config" ]
  deps = [ ":expired_callback_interface" ]
  subsystem_name = "resourceschedule"
  part_name = "background_task_mgr"
  external_deps = [
    "ability_runtime:wantagent_innerkits",
    "c_utils:utils",
    "hilog:libhilog",
    "ipc:ipc_core",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]
}