BUILD.gn 4.4 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

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",
]

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 已提交
48 49
    "//base/startup/init/interfaces/innerkits/hookmgr/hookmgr.c",
    "//base/startup/init/interfaces/innerkits/modulemgr/modulemgr.c",
M
Mupceet 已提交
50 51 52 53
  ]
  sources += modulemgr_sources
  sources += init_common_sources

M
init  
Mupceet 已提交
54
  include_dirs = [ "//base/startup/init/services/init/include" ]
M
Mupceet 已提交
55 56

  deps = [
M
init  
Mupceet 已提交
57 58 59 60 61 62 63 64
    "//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/base:parameterbase",
    "//base/startup/init/services/param/linux:param_init",
    "//base/startup/init/services/utils:libinit_utils",
M
Mupceet 已提交
65 66 67 68 69 70
  ]

  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 已提交
71
    "//base/startup/init/ueventd:libueventd_ramdisk_static",
M
Mupceet 已提交
72 73 74 75
    "//third_party/bounds_checking_function:libsec_static",
    "//third_party/cJSON:cjson_static",
  ]

M
init  
Mupceet 已提交
76 77 78
  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" ]
M
Mupceet 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119

  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 = [ "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" ]
  }
120 121 122
  if (asan_detector) {
    defines += [ "ASAN_DETECTOR" ]
  }
M
Mupceet 已提交
123

M
Mupceet 已提交
124
  if (enable_ohos_startup_init_feature_loader) {
M
Mupceet 已提交
125 126 127
    defines += [ "PRODUCT_RK" ]
  }
  version_script = get_label_info(
M
init  
Mupceet 已提交
128
                       "//base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
M
Mupceet 已提交
129
                       "target_gen_dir") + "/" + get_label_info(
M
init  
Mupceet 已提交
130
                       "//base/startup/init/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
M
Mupceet 已提交
131 132 133 134 135 136 137 138 139 140
                       "name") + stub_version_script_suffix
  defines += [ "_GNU_SOURCE" ]
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  install_enable = true
  part_name = "init"
}