# Copyright (c) 2021-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("//base/startup/init/begetd.gni") if (!defined(ohos_lite) || enable_ohos_startup_init_feature_begetctl_liteos) { syspara_sources = [ "syscap/init_syscap.c", "syspara/param_comm.c", "syspara/parameter.c", "syspara/sysversion.c", ] } config("exported_header_files") { visibility = [ ":*" ] include_dirs = [ "//base/startup/init/interfaces/innerkits/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//base/startup/init/interfaces/innerkits/include/token", "//base/startup/init/services/include", ] } include_common = [ "./include", "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//third_party/bounds_checking_function/include", "//base/startup/init/services/include", "//base/startup/init/services/include/param", "//base/startup/init/interfaces/innerkits/fd_holder", "//base/startup/init/services/param/include", "//base/startup/init/interfaces/innerkits/include", "//base/startup/init/interfaces/innerkits/include/syspara", "//base/startup/init/interfaces/hals", "//base/startup/init/interfaces/innerkits/syspara", ] if (defined(ohos_lite)) { import("//build/lite/config/component/lite_component.gni") import("//build/lite/ndk/ndk.gni") if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") { shared_library("libbegetutil") { cflags = [ "-fPIC" ] defines = [ "_GNU_SOURCE", "OHOS_LITE", "USE_MBEDTLS", ] sources = [] include_dirs = include_common public_configs = [ ":exported_header_files" ] deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/startup/init/services/modules/init_hook:inithook", "//third_party/bounds_checking_function:libsec_shared", "//third_party/mbedtls:mbedtls_shared", ] deps += [ "//base/startup/init/services/log:init_log", "//base/startup/init/services/utils:libinit_utils", ] if (enable_ohos_startup_init_feature_begetctl_liteos) { sources += syspara_sources defines += [ "LITEOS_SUPPORT" ] deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] } else { sources += [ "syscap/init_syscap.c" ] } if (ohos_kernel_type == "liteos_a") { defines += [ "__LITEOS_A__" ] deps += [ "//base/startup/init/services/param/liteos:param_client_lite" ] } else if (ohos_kernel_type == "linux") { sources += [ "socket/init_socket.c" ] defines += [ "__LINUX__" ] deps += [ "//base/startup/init/services/loopevent:loopevent", "//base/startup/init/services/param/base:parameterbase", "//base/startup/init/services/param/linux:param_client", ] } } } if (ohos_kernel_type == "liteos_m") { static_library("libbegetutil") { public_configs = [ ":exported_header_files" ] defines = [ "_GNU_SOURCE", "OHOS_LITE", "__LITEOS_M__", ] include_dirs = include_common deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", "//base/startup/init/services/modules/init_hook:inithook", "//third_party/bounds_checking_function:libsec_static", ] sources = [] if (enable_ohos_startup_init_feature_begetctl_liteos) { deps += [ "$ohos_product_adapter_dir/utils/sys_param:hal_sysparam" ] defines += [ "LITEOS_SUPPORT" ] sources += syspara_sources } else { sources += [ "syscap/init_syscap.c" ] } if (enable_ohos_startup_init_lite_use_thirdparty_mbedtls) { deps += [ "//third_party/mbedtls:mbedtls" ] defines += [ "USE_MBEDTLS" ] } if (enable_ohos_startup_init_feature_begetctl_liteos) { deps += [ "//base/startup/init/services/log:init_log", "//base/startup/init/services/param/liteos:param_client_lite", "//base/startup/init/services/utils:libinit_utils", ] } } } lite_component("parameter") { features = [ ":libbegetutil" ] } ndk_lib("parameter_notes") { if (ohos_kernel_type != "liteos_m") { lib_extension = ".so" } deps = [ ":libbegetutil" ] head_files = [ "//base/startup/init/interfaces/innerkits/include/syspara" ] } group("libbeget_proxy") { } } else { import("//build/ohos.gni") modulemgr_sources = [ "hookmgr/hookmgr.c", "modulemgr/modulemgr.c", ] ohos_shared_library("libbegetutil") { sources = [ "fd_holder/fd_holder.c", "reboot/init_reboot_innerkits.c", "service_control/service_control.c", ] sources += syspara_sources sources += [ "syspara/param_wrapper.cpp" ] sources += modulemgr_sources defines = [ "INIT_AGENT", "_GNU_SOURCE", "USE_MBEDTLS", ] if (target_cpu == "arm64") { defines += [ "SUPPORT_64BIT" ] } include_dirs = include_common deps = [ "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static", "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd", "//base/startup/init/interfaces/innerkits/fd_holder:fdholder", "//base/startup/init/interfaces/innerkits/file:libfile", "//base/startup/init/interfaces/innerkits/socket:libsocket", "//base/startup/init/services/log:agent_log", "//base/startup/init/services/loopevent:loopevent", "//base/startup/init/services/param/linux:param_client", "//base/startup/init/services/utils:libinit_utils", "//third_party/bounds_checking_function:libsec_shared", "//third_party/mbedtls:mbedtls_shared", ] if (use_musl == false) { deps += [ "//base/startup/init/services/param/base:parameterbase" ] } else { deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ] } external_deps = [ "c_utils:utils", "hilog_native:libhilog_base", ] public_configs = [ ":exported_header_files" ] part_name = "init" subsystem_name = "startup" install_images = [ "system", "updater", ] } # watcher lib must separate compilation avoid interdependence. ohos_shared_library("libbeget_proxy") { defines = [ "INIT_AGENT", "_GNU_SOURCE", "USE_MBEDTLS", ] sources = [ "//base/startup/init/device_info/device_info.cpp", "service_watcher/service_watcher.c", ] include_dirs = include_common deps = [ ":libbegetutil", "//third_party/bounds_checking_function:libsec_shared", ] if (enable_ohos_startup_init_feature_watcher) { sources += [ "//base/startup/init/services/param/watcher/agent/watcher.cpp", "//base/startup/init/services/param/watcher/agent/watcher_manager_kits.cpp", "//base/startup/init/services/param/watcher/agent/watcher_manager_proxy.cpp", "//base/startup/init/services/param/watcher/agent/watcher_stub.cpp", ] include_dirs += [ "//base/startup/init/services/param/watcher/include", "//base/startup/init/services/log", ] } else { defines += [ "NO_PARAM_WATCHER" ] } if (enable_ohos_startup_init_feature_deviceinfo) { sources += [ "//base/startup/init/device_info/device_info_kits.cpp", "//base/startup/init/device_info/device_info_load.cpp", "//base/startup/init/device_info/device_info_proxy.cpp", ] defines += [ "PARAM_FEATURE_DEVICEINFO" ] } else { sources += [ "//base/startup/init/interfaces/innerkits/syspara/param_comm.c" ] } external_deps = [ "c_utils:utils", "hilog_native:libhilog_base", "ipc:ipc_single", "samgr:samgr_proxy", ] public_configs = [ ":exported_header_files" ] part_name = "init" subsystem_name = "startup" install_images = [ "system" ] } ohos_static_library("libbegetutil_static") { sources = syspara_sources sources += [ "syspara/param_wrapper.cpp" ] defines = [ "INIT_AGENT", "_GNU_SOURCE", "USE_MBEDTLS", ] if (target_cpu == "arm64") { defines += [ "SUPPORT_64BIT" ] } include_dirs = include_common deps = [ "//base/startup/init/services/log:agent_log", "//base/startup/init/services/loopevent:loopevent", "//base/startup/init/services/param/linux:param_client", "//base/startup/init/services/utils:libinit_utils", "//third_party/bounds_checking_function:libsec_shared", "//third_party/mbedtls:mbedtls_shared", ] if (use_musl == false) { deps += [ "//base/startup/init/services/param/base:parameterbase" ] } else { deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ] } external_deps = [ "c_utils:utils", "hilog_native:libhilog_base", ] part_name = "init" subsystem_name = "startup" } } group("innergroup") { deps = [ ":libbegetutil" ] if (build_seccomp) { deps += [ "seccomp:seccomp" ] } if (!defined(ohos_lite)) { deps += [ ":libbeget_proxy", "file:libfile", "init_module_engine:modulegroup", "socket:libsocket", ] } }