BUILD.gn 4.5 KB
Newer Older
M
Mupceet 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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
# 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.
import("//base/startup/init_lite/begetd.gni")

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 = [
    "//base/startup/init_lite/interfaces/innerkits/hookmgr/hookmgr.c",
    "//base/startup/init_lite/interfaces/innerkits/modulemgr/modulemgr.c",
  ]
  sources += modulemgr_sources
  sources += init_common_sources

  include_dirs = [ "//base/startup/init_lite/services/init/include" ]

  deps = [
    "//base/startup/init_lite/interfaces/innerkits/control_fd:libcontrolfd",
    "//base/startup/init_lite/interfaces/innerkits/fd_holder:fdholder",
    "//base/startup/init_lite/interfaces/innerkits/fs_manager:libfsmanager_static",
    "//base/startup/init_lite/interfaces/innerkits/sandbox:sandbox",
    "//base/startup/init_lite/services/loopevent:loopevent",
    "//base/startup/init_lite/services/param/base:parameterbase",
    "//base/startup/init_lite/services/param/linux:param_init",
    "//base/startup/init_lite/services/utils:libinit_utils",
  ]

  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",
    "//base/startup/init_lite/ueventd:libueventd_ramdisk_static",
    "//third_party/bounds_checking_function:libsec_static",
    "//third_party/cJSON:cjson_static",
  ]

  deps += [ "//base/startup/init_lite/interfaces/innerkits/init_module_engine:libinit_stub_versionscript" ]
  deps += [ "//base/startup/init_lite/interfaces/innerkits/init_module_engine:init_module_engine_sources" ]
  deps += [ "//base/startup/init_lite/services/modules:static_modules" ]

  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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140

  if (defined(product_name) && product_name == "rk3568") {
    defines += [ "PRODUCT_RK" ]
  }
  version_script = get_label_info(
                       "//base/startup/init_lite/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
                       "target_gen_dir") + "/" + get_label_info(
                       "//base/startup/init_lite/interfaces/innerkits/init_module_engine:libinit_stub_versionscript",
                       "name") + stub_version_script_suffix
  defines += [ "_GNU_SOURCE" ]
  install_images = [
    "system",
    "updater",
    "ramdisk",
  ]
  install_enable = true
  part_name = "init"
}