# Copyright (c) 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("//base/update/updateservice/updateengine.gni")
import("//build/ohos.gni")
import("$updateengine_root_path/services/core/ability/sqlite/sqlite.gni")
import("$updateengine_root_path/services/firmware/firmware.gni")
import("$updateengine_root_path/services/startup/startup.gni")
declare_args() {
ability_ability_base_enable = true
if (!defined(global_parts_info.ability_ability_base)) {
ability_ability_base_enable = false
}
preference_native_preferences_enable = true
if (!defined(global_parts_info.distributeddatamgr_preferences)) {
preference_native_preferences_enable = false
}
update_service_enable_run_on_demand_qos = true
if (!defined(global_parts_info.update_service_enable_run_on_demand_qos)) {
update_service_enable_run_on_demand_qos = false
}
}
sa_sources = [
"$updateengine_root_path/services/core/ability/adapter/src/config_parse.cpp",
"$updateengine_root_path/services/core/ability/adapter/src/device_adapter.cpp",
"$updateengine_root_path/services/core/ability/alarm/src/timer_manager.cpp",
"$updateengine_root_path/services/core/ability/status_cache/src/status_cache.cpp",
"$updateengine_root_path/services/core/ability/utils/src/file_utils.cpp",
"$updateengine_root_path/services/core/ability/utils/src/sha256_utils.cpp",
"$updateengine_root_path/services/core/ability/utils/src/time_utils_proxy.cpp",
"$updateengine_root_path/services/engine/src/progress_thread.cpp",
"$updateengine_root_path/services/engine/src/stream_progress_thread.cpp",
"$updateengine_root_path/services/engine/src/update_service.cpp",
"$updateengine_root_path/services/engine/src/update_service_cache.cpp",
"$updateengine_root_path/services/engine/src/update_service_impl_firmware.cpp",
"$updateengine_root_path/services/engine/src/update_service_impl_manager.cpp",
"$updateengine_root_path/services/engine/src/update_service_local_updater.cpp",
"$updateengine_root_path/services/engine/src/update_service_restorer.cpp",
"$updateengine_root_path/services/engine/src/update_service_util_hmos.cpp",
]
if (ability_ability_base_enable || ability_ability_runtime_enable) {
sa_sources += [
"$updateengine_root_path/services/core/ability/alarm/src/alarm_timer_utils.cpp",
"$updateengine_root_path/services/core/ability/callback/src/base_callback_utils.cpp",
"$updateengine_root_path/services/engine/src/update_notify.cpp",
]
} else {
sa_sources += [ "$updateengine_root_path/services/core/ability/callback/src/base_callback_utils_empty.cpp" ]
}
if (communication_netmanager_base_enable) {
sa_sources += [
"$updateengine_root_path/services/utils/src/dupdate_net_manager.cpp",
"$updateengine_root_path/services/utils/src/dupdate_net_observer.cpp",
]
} else {
sa_sources += [
"$updateengine_root_path/services/utils/src/dupdate_net_manager_empty.cpp",
]
}
if (preference_native_preferences_enable) {
sa_sources += [ "$updateengine_root_path/services/core/ability/preference/src/preference_utils.cpp" ]
} else {
sa_sources += [ "$updateengine_root_path/services/core/ability/preference/src/preference_utils_empty.cpp" ]
}
sa_sources += firmware_src
sa_sources += sqlite_src
sa_sources += startup_src
sa_include_dirs = [
"$updateengine_root_path/services/auto_update/include",
"$updateengine_root_path/services/bi_report/include",
"$updateengine_root_path/services/callback/include",
"$updateengine_root_path/services/core/ability/adapter/include",
"$updateengine_root_path/services/core/ability/alarm/include",
"$updateengine_root_path/services/core/ability/callback/include",
"$updateengine_root_path/services/core/ability/common/include",
"$updateengine_root_path/services/core/ability/model/include",
"$updateengine_root_path/services/core/ability/net/include",
"$updateengine_root_path/services/core/ability/preference/include",
"$updateengine_root_path/services/core/ability/status_cache/include",
"$updateengine_root_path/services/core/ability/utils/include",
"$updateengine_root_path/services/engine/include",
"$updateengine_root_path/services/osal/include",
"$updateengine_root_path/services/service/include",
"$updateengine_root_path/services/utils/include",
"$updateengine_root_path/interfaces/inner_api/common/include",
"$updateengine_root_path/interfaces/inner_api/include",
]
if (!relational_store_native_rdb_enable) {
sa_include_dirs += [
"//base/update/updateservice/services/core/ability/sqlite/core/include",
]
}
sa_include_dirs += firmware_include
sa_include_dirs += sqlite_include
sa_include_dirs += startup_include
sa_include_dirs +=
[ "//base/update/updateservice/interfaces/innner_api/modulemgr/include" ]
sa_deps = [
"$updateengine_root_path/foundations:update_foundations",
"$updateengine_root_path/interfaces/inner_api/engine:$updateengine_inner_library_name",
"$updateengine_root_path/interfaces/inner_api/modulemgr:update_module_mgr",
]
sa_deps += firmware_deps
sa_deps += startup_deps
sa_external_deps = [
"ability_base:configuration",
"ability_base:session_info",
"access_token:libaccesstoken_sdk",
"access_token:libtokenid_sdk",
"bundle_framework:appexecfwk_core",
"cJSON:cjson",
"c_utils:utils", # refbase
"curl:curl_shared",
"hilog:libhilog",
"hisysevent:libhisysevent",
"init:libbegetutil",
"ipc:ipc_core",
"libxml2:libxml2",
"openssl:libcrypto_shared",
"openssl:libssl_shared",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
"storage_service:storage_manager_sa_proxy",
"updater:libfsmanager", # "fs_manager/mount.h"
"updater:libpackage_shared", # "package/package.h"
"updater:libupdater_shared", # "updaterkits/updaterkits.h"
]
if (ability_ability_base_enable) {
sa_external_deps += [
"ability_base:base",
"ability_base:want",
"ability_runtime:wantagent_innerkits",
"jsoncpp:jsoncpp",
"time_service:time_client",
]
}
if (ability_ability_runtime_enable) {
sa_external_deps += [
"ability_runtime:ability_connect_callback_stub",
"ability_runtime:extension_manager",
"jsoncpp:jsoncpp",
]
}
if (communication_netmanager_base_enable) {
sa_external_deps += [ "netmanager_base:net_conn_manager_if" ]
}
if (preference_native_preferences_enable) {
sa_external_deps += [ "preferences:native_preferences" ]
}
sa_external_deps += firmware_external_deps
sa_external_deps += sqlite_external_deps
sa_external_deps += startup_external_deps
sa_defines = [
"DUAL_ADAPTER",
"UPDATE_SERVICE",
]
if (ability_ability_base_enable) {
sa_defines += [ "ABILITY_BASE_ENABLE" ]
}
if (ability_ability_runtime_enable) {
sa_defines += [ "ABILITY_RUNTIME_ENABLE" ]
}
if (communication_netmanager_base_enable) {
sa_defines += [ "NETMANAGER_BASE_ENABLE" ]
}
if (preference_native_preferences_enable) {
sa_defines += [ "NATIVE_PREFERENCES_ENABLE" ]
}
if (update_service_enable_run_on_demand_qos) {
sa_defines += [ "UPDATE_SERVICE_ENABLE_RUN_ON_DEMAND_QOS" ]
}
sa_defines += sqlite_defines
sa_cflags = [
"-fPIC",
"-Os",
"-Werror",
"-fstack-protector-strong",
]