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
  ]
A
an_xinwei 已提交
72 73 74 75 76
  if (use_musl == false) {
    deps += [ "//base/startup/init/services/param/base:parameterbase" ]
  } else {
    deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
  }
M
Mupceet 已提交
77 78 79 80 81

  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 已提交
82
    "//base/startup/init/ueventd:libueventd_ramdisk_static",
M
Mupceet 已提交
83 84 85 86
    "//third_party/bounds_checking_function:libsec_static",
    "//third_party/cJSON:cjson_static",
  ]

M
init  
Mupceet 已提交
87 88 89
  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" ]
90
  deps += [ "${FSCRYPT_PATH}/libfscrypt:libfscryptutils_static" ]
M
Mupceet 已提交
91 92 93 94 95 96 97 98 99 100

  cflags = []

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

X
<feat>  
xiacong 已提交
101 102 103 104
  if (build_seccomp) {
    cflags += [ "-DWITH_SECCOMP" ]
  }

M
Mupceet 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
  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" ]
  }
  if (support_jsapi) {
    defines += [ "SUPPORT_PROFILER_HIDEBUG" ]
  }
136 137 138
  if (asan_detector) {
    defines += [ "ASAN_DETECTOR" ]
  }
M
Mupceet 已提交
139

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