BUILD.gn 4.9 KB
Newer Older
M
Mupceet 已提交
1 2 3 4 5 6 7 8 9 10 11 12
# 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.
M
init  
Mupceet 已提交
13
import("//base/startup/init/begetd.gni")
M
Mupceet 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26

init_common_sources = [
  "../init_capability.c",
  "../init_common_cmds.c",
  "../init_common_service.c",
  "../init_config.c",
  "../init_group_manager.c",
  "../init_service_file.c",
  "../init_service_manager.c",
  "../init_service_socket.c",
  "../main.c",
]

27 28 29
FSCRYPT_PATH =
    "//foundation/filemanagement/storage_service/services/storage_daemon"

M
Mupceet 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
import("//build/ohos.gni")
import("//build/ohos/native_stub/native_stub.gni")

ohos_executable("init") {
  sources = [
    "../adapter/init_adapter.c",
    "../standard/device.c",
    "../standard/fd_holder_service.c",
    "../standard/init.c",
    "../standard/init_cmdexecutor.c",
    "../standard/init_cmds.c",
    "../standard/init_control_fd_service.c",
    "../standard/init_jobs.c",
    "../standard/init_mount.c",
    "../standard/init_reboot.c",
    "../standard/init_service.c",
    "../standard/init_signal_handler.c",
    "../standard/switch_root.c",
  ]

  modulemgr_sources = [
M
init  
Mupceet 已提交
51 52
    "//base/startup/init/interfaces/innerkits/hookmgr/hookmgr.c",
    "//base/startup/init/interfaces/innerkits/modulemgr/modulemgr.c",
M
Mupceet 已提交
53 54 55 56
  ]
  sources += modulemgr_sources
  sources += init_common_sources

57 58
  include_dirs = [
    "//base/startup/init/services/init/include",
C
cheng_jinsong 已提交
59
    "//base/startup/init/services/modules/reboot",
60 61
    "${FSCRYPT_PATH}/include/libfscrypt",
  ]
M
Mupceet 已提交
62 63

  deps = [
M
init  
Mupceet 已提交
64 65 66 67 68 69 70
    "//base/startup/init/interfaces/innerkits/control_fd:libcontrolfd",
    "//base/startup/init/interfaces/innerkits/fd_holder:fdholder",
    "//base/startup/init/interfaces/innerkits/fs_manager:libfsmanager_static",
    "//base/startup/init/interfaces/innerkits/sandbox:sandbox",
    "//base/startup/init/services/loopevent:loopevent",
    "//base/startup/init/services/param/linux:param_init",
    "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
71
  ]
72
  deps += [ "//base/startup/init/services/param/base:param_base" ]
M
Mupceet 已提交
73 74 75 76 77

  deps += [
    "//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
    "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken",
    "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc",
M
init  
Mupceet 已提交
78
    "//base/startup/init/ueventd:libueventd_ramdisk_static",
M
Mupceet 已提交
79 80 81 82
    "//third_party/bounds_checking_function:libsec_static",
    "//third_party/cJSON:cjson_static",
  ]

M
init  
Mupceet 已提交
83 84 85
  deps += [ "//base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_versionscript" ]
  deps += [ "//base/startup/init/interfaces/innerkits/init_module_engine:init_module_engine_sources" ]
  deps += [ "//base/startup/init/services/modules:static_modules" ]
86
  deps += [ "${FSCRYPT_PATH}/libfscrypt:libfscryptutils_static" ]
M
Mupceet 已提交
87 88 89 90 91 92 93 94 95 96

  cflags = []

  if (use_musl) {
    deps += [
      "//third_party/mksh:sh",
      "//third_party/toybox:toybox",
    ]
  }

X
<feat>  
xiacong 已提交
97 98 99 100
  if (build_seccomp) {
    cflags += [ "-DWITH_SECCOMP" ]
  }

M
Mupceet 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  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 = [ "PARAM_SUPPORT_TRIGGER" ]
  if (param_test) {
    defines += [
      "OHOS_SERVICE_DUMP",
      "INIT_TEST",
    ]
  }

  if (target_cpu == "arm64") {
    defines += [ "SUPPORT_64BIT" ]
  }

  if (!enable_ramdisk) {
    defines += [ "DISABLE_INIT_TWO_STAGES" ]
  }
129
  if (defined(global_parts_info.developtools_profiler)) {
M
Mupceet 已提交
130
    defines += [ "SUPPORT_PROFILER_HIDEBUG" ]
131
    external_deps = [ "profiler:libhidebug_init" ]
M
Mupceet 已提交
132
  }
133 134 135
  if (asan_detector) {
    defines += [ "ASAN_DETECTOR" ]
  }
M
Mupceet 已提交
136

M
Mupceet 已提交
137
  if (enable_ohos_startup_init_feature_loader) {
M
Mupceet 已提交
138 139 140
    defines += [ "PRODUCT_RK" ]
  }
  version_script = get_label_info(
M
init  
Mupceet 已提交
141
                       "//base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
M
Mupceet 已提交
142
                       "target_gen_dir") + "/" + get_label_info(
M
init  
Mupceet 已提交
143
                       "//base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
M
Mupceet 已提交
144 145
                       "name") + stub_version_script_suffix
  defines += [ "_GNU_SOURCE" ]
C
cheng_jinsong 已提交
146 147 148
  if (use_musl) {
    defines += [ "__MUSL__" ]
  }
M
Mupceet 已提交
149 150 151 152 153 154 155
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  install_enable = true
  part_name = "init"
156
  subsystem_name = "startup"
M
Mupceet 已提交
157
}