# Copyright (c) 2020-2021 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. init_common_sources = [ "init/init_capability.c", "init/init_common_cmds.c", "init/init_common_service.c", "init/init_config.c", "init/init_group_manager.c", "init/init_service_file.c", "init/init_service_manager.c", "init/init_service_socket.c", "init/main.c", ] if (defined(ohos_lite)) { # feature: init executable("init_lite") { output_name = "init" defines = [ "_GNU_SOURCE", #syscall function need this macro definition "OHOS_LITE", ] defines += [ "__MUSL__" ] sources = [ "init/adapter/init_adapter.c", "init/lite/init.c", "init/lite/init_cmds.c", "init/lite/init_jobs.c", "init/lite/init_reboot.c", "init/lite/init_service.c", "init/lite/init_signal_handler.c", "log/init_log.c", "utils/init_hashmap.c", "utils/init_utils.c", "utils/list.c", ] sources += init_common_sources include_dirs = [ "//base/startup/init_lite/services/include", "//base/startup/init_lite/services/init/include", "//base/startup/init_lite/services/log", "//base/startup/init_lite/services/loopevent/include", "//base/startup/init_lite/interfaces/innerkits/include", "//third_party/cJSON", "//third_party/bounds_checking_function/include", "//base/startup/syspara_lite/interfaces/kits", "//base/hiviewdfx/hilog_lite/interfaces/native/kits", "//base/startup/init_lite/interfaces/innerkits/fd_holder", ] cflags = [ "-Wall" ] deps = [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/startup/init_lite/initsync:initsync", "//base/startup/init_lite/services/loopevent:loopevent", "//base/startup/syspara_lite/frameworks/parameter:parameter", "//build/lite/config/component/cJSON:cjson_shared", "//third_party/bounds_checking_function:libsec_shared", ] ldflags = [] if (ohos_kernel_type == "liteos_a") { include_dirs += [ "//kernel/liteos_a/syscall", "//base/startup/init_lite/interfaces/kits", "//base/startup/init_lite/initsync/include", ] deps += [ "//base/startup/init_lite/initsync:initsync" ] } if (ohos_kernel_type == "linux") { defines += [ "NEED_EXEC_RCS_LINUX" ] defines += [ "_GNU_SOURCE" ] ldflags += [ "-lm", "-lpthread", ] deps += [ "//third_party/mksh", "//third_party/toybox", ] } } if (ohos_build_type == "debug") { group("unittest") { deps = [ "//base/startup/init_lite/test/unittest/common:unittest" ] } } } else { import("//base/startup/init_lite/begetd.gni") import("//build/ohos.gni") ohos_executable("init") { sources = [ "//base/startup/init_lite/interfaces/innerkits/fd_holder/fd_holder_internal.c", "init/adapter/init_adapter.c", "init/standard/device.c", "init/standard/fd_holder_service.c", "init/standard/init.c", "init/standard/init_cmds.c", "init/standard/init_jobs.c", "init/standard/init_mount.c", "init/standard/init_plugin_manager.c", "init/standard/init_reboot.c", "init/standard/init_service.c", "init/standard/init_signal_handler.c", "init/standard/switch_root.c", ] sources += init_common_sources include_dirs = [ "//base/security/access_token/interfaces/innerkits/token_setproc/include", "//base/security/access_token/interfaces/innerkits/nativetoken/include", "//base/startup/init_lite/services/include/param", "//base/startup/init_lite/services/include", "//base/startup/init_lite/services/init/include", "//base/startup/init_lite/services/log", "//base/startup/init_lite/interfaces/innerkits/include", "//base/startup/init_lite/services/loopevent/include", "//base/startup/init_lite/interfaces/innerkits/include", "//base/startup/init_lite/interfaces/innerkits/fd_holder", "//base/startup/init_lite/ueventd/include", "//third_party/cJSON", "//third_party/bounds_checking_function/include", ] deps = [ "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", "//base/startup/init_lite/interfaces/innerkits:libfsmanager_static", "//base/startup/init_lite/services/log:init_log", "//base/startup/init_lite/services/loopevent:loopevent", "//base/startup/init_lite/services/param:param_service", "//base/startup/init_lite/services/utils:libinit_tools", "//base/startup/init_lite/services/utils:libinit_utils", "//base/startup/init_lite/ueventd:libueventd_ramdisk_static", "//third_party/bounds_checking_function:libsec_static", "//third_party/cJSON:cjson_static", ] cflags = [] if (use_musl) { deps += [ "//third_party/mksh:sh", "//third_party/toybox:toybox", ] } if (build_selinux) { include_dirs += [ "//third_party/selinux/libselinux/include/", "//base/security/selinux/interfaces/policycoreutils/include/", ] deps += [ "//base/security/selinux:libload_policy", "//base/security/selinux:librestorecon", "//third_party/selinux:libselinux", ] cflags += [ "-DWITH_SELINUX" ] } defines = [ "OHOS_SERVICE_DUMP" ] if (!enable_ramdisk) { defines += [ "DISABLE_INIT_TWO_STAGES" ] } if (defined(product_name) && product_name == "rk3568") { defines += [ "PRODUCT_RK" ] } defines += [ "_GNU_SOURCE" ] install_images = [ "system", "updater", "ramdisk", ] install_enable = true part_name = "init" } group("startup_init") { deps = [ ":init", ":init_etc", "//base/startup/init_lite/services/param:param_client", "//base/startup/init_lite/services/param:param_service", ] if (param_feature_watcher) { deps += [ "//base/startup/init_lite/services/param/watcher:param_watcher", "//base/startup/init_lite/services/param/watcher:param_watcher.rc", "//base/startup/init_lite/services/param/watcher:param_watcheragent", "//base/startup/init_lite/services/param/watcher/sa_profile:param_watcher_profile", ] } } # init etc files group ohos_prebuilt_etc("init.cfg") { if (!enable_ramdisk) { source = "//base/startup/init_lite/services/etc/init.without_two_stages.cfg" } else { source = "//base/startup/init_lite/services/etc/init.cfg" } part_name = "init" } ohos_prebuilt_etc("passwd") { source = "//base/startup/init_lite/services/etc/passwd" install_images = [ "system", "updater", ] part_name = "init" } ohos_prebuilt_etc("group") { source = "//base/startup/init_lite/services/etc/group" install_images = [ "system", "updater", ] part_name = "init" } ohos_prebuilt_etc("init.usb.cfg") { source = "//base/startup/init_lite/services/etc/init.usb.cfg" part_name = "init" } ohos_prebuilt_etc("init.usb.configfs.cfg") { source = "//base/startup/init_lite/services/etc/init.usb.configfs.cfg" part_name = "init" } ohos_prebuilt_etc("ohos.para") { source = "//base/startup/init_lite/services/etc/param/ohos.para" part_name = "init" module_install_dir = "etc/param" } ohos_prebuilt_etc("ohos.para.dac") { source = "//base/startup/init_lite/services/etc/param/ohos.para.dac" part_name = "init" module_install_dir = "etc/param" } ohos_prebuilt_etc("boot.group") { source = "//base/startup/init_lite/services/etc/device.boot.group.cfg" part_name = "init" } group("init_etc") { deps = [ ":boot.group", ":group", ":init.cfg", ":init.usb.cfg", ":init.usb.configfs.cfg", ":ohos.para", ":ohos.para.dac", ":passwd", ] } }