BUILD.gn 6.2 KB
Newer Older
M
Mupceet 已提交
1
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
Z
zhong_ning 已提交
2 3 4 5 6 7 8 9 10 11
# 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
H
handyohos 已提交
12
# limitations under the License.
M
Mupceet 已提交
13
import("//base/startup/init_lite/begetd.gni")
Y
yanghongliang 已提交
14

M
Mupceet 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
common_include_dirs = [
  "//base/startup/init_lite/services/begetctl",
  "//base/startup/init_lite/services/begetctl/shell",
  "//base/startup/init_lite/services/param/include",
  "//base/startup/init_lite/services/param/adapter",
  "//base/startup/init_lite/services/param/linux",
  "//base/startup/init_lite/services/param/base",
  "//base/startup/init_lite/services/include/param",
  "//base/startup/init_lite/services/include",
  "//base/startup/init_lite/services/loopevent/include",
  "//base/startup/init_lite/services/init/include",
  "//base/startup/init_lite/services/log",
  "//base/startup/init_lite/interfaces/innerkits/include",
  "//third_party/bounds_checking_function/include",
]

M
Mupceet 已提交
31 32 33 34 35 36 37
if (defined(ohos_lite)) {
  executable("begetctl") {
    output_name = "begetctl"
    sources = [
      "main.c",
      "param_cmd.c",
      "shell/shell_bas.c",
X
xionglei6 已提交
38
    ]
M
Mupceet 已提交
39 40 41
    defines = [
      "_GNU_SOURCE",  #syscall function need this macro definition
      "__MUSL__",
M
Mupceet 已提交
42
      "OHOS_LITE",
M
Mupceet 已提交
43
    ]
M
Mupceet 已提交
44 45 46
    if (param_test) {
      sources += [ "//base/startup/init_lite/test/moduletest/syspara.cpp" ]
    }
M
Mupceet 已提交
47 48

    include_dirs = common_include_dirs
M
Mupceet 已提交
49 50 51
    deps = [
      "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
      "//base/startup/init_lite/interfaces/innerkits:libbegetutil",
M
Mupceet 已提交
52
      "//base/startup/init_lite/services/utils:libinit_utils",
M
Mupceet 已提交
53 54
      "//build/lite/config/component/cJSON:cjson_static",
      "//third_party/bounds_checking_function:libsec_static",
X
xionglei6 已提交
55 56
    ]
  }
M
Mupceet 已提交
57
  group("begetctl_cmd") {
M
Mupceet 已提交
58 59
    if (enable_ohos_startup_init_feature_begetctl_liteos &&
        ohos_kernel_type != "liteos_m") {
M
Mupceet 已提交
60 61 62
      deps = [ ":begetctl" ]
    }
  }
M
Mupceet 已提交
63 64
} else {
  import("//build/ohos.gni")
X
xionglei6 已提交
65

M
Mupceet 已提交
66 67 68
  ohos_executable("begetctl") {
    sources = [
      "bootchart_cmd.c",
M
Mupceet 已提交
69
      "dump_service.c",
M
Mupceet 已提交
70 71 72
      "init_cmd_reboot.c",
      "main.c",
      "misc_daemon.cpp",
73
      "modulectl.c",
M
Mupceet 已提交
74 75 76 77 78
      "param_cmd.c",
      "sandbox.cpp",
      "service_control.c",
      "shell/shell_bas.c",
    ]
X
xionglei6 已提交
79

M
Mupceet 已提交
80
    defines = [ "_GNU_SOURCE" ]
X
xionglei6 已提交
81

M
Mupceet 已提交
82 83 84 85 86 87 88
    if (defined(product_name) && product_name == "rk3568") {
      defines += [ "PRODUCT_RK" ]
    }

    include_dirs = [
      "//third_party/bounds_checking_function/include",
      "//base/startup/init_lite/interfaces/innerkits/sandbox/include",
M
Mupceet 已提交
89
      "//base/startup/init_lite/interfaces/innerkits/control_fd",
X
xionglei6 已提交
90
    ]
M
Mupceet 已提交
91
    include_dirs += common_include_dirs
M
Mupceet 已提交
92 93
    deps = [
      "//base/startup/init_lite/interfaces/innerkits:libbegetutil",
M
Mupceet 已提交
94
      "//base/startup/init_lite/interfaces/innerkits/control_fd:libcontrolfd",
M
Mupceet 已提交
95
      "//third_party/bounds_checking_function:libsec_shared",
X
xionglei6 已提交
96
    ]
M
Mupceet 已提交
97
    external_deps = [ "utils_base:utils" ]
M
Mupceet 已提交
98 99

    if (param_test) {
M
Mupceet 已提交
100 101 102
      sources += [
        "//base/startup/init_lite/test/moduletest/param_test_cmds.c",
        "//base/startup/init_lite/test/moduletest/syspara.cpp",
M
Mupceet 已提交
103
      ]
M
Mupceet 已提交
104
      deps += [ "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy" ]
M
Mupceet 已提交
105 106 107 108 109 110 111 112 113 114 115 116
      defines += [
        "OHOS_SERVICE_DUMP",
        "INIT_TEST",
      ]
    }

    if (build_selinux) {
      include_dirs += [
        "//third_party/selinux/libselinux/include/",
        "//base/security/selinux/interfaces/policycoreutils/include/",
      ]
      deps += [ "//third_party/selinux:libselinux" ]
M
Mupceet 已提交
117
      external_deps += [ "selinux:libparaperm_checker" ]
M
Mupceet 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }

    symlink_target_name = [
      "misc_daemon",
      "reboot",
      "devctl",
      "service",
      "service_control",
      "start_service",
      "stop_service",
      "service",
      "sandbox",
M
Mupceet 已提交
131
      "dump_service",
M
Mupceet 已提交
132 133 134 135
    ]
    install_images = [ "system" ]
    install_enable = true
    part_name = "init"
X
xionglei6 已提交
136 137
  }

M
Mupceet 已提交
138 139 140 141 142 143 144 145
  ohos_executable("paramshell") {
    sources = [
      "param_cmd.c",
      "shell/shell_bas.c",
      "shell/shell_main.c",
    ]

    defines = [ "_GNU_SOURCE" ]
M
Mupceet 已提交
146
    include_dirs = common_include_dirs
M
Mupceet 已提交
147 148 149 150 151 152 153 154 155 156
    deps = [
      "//base/startup/init_lite/interfaces/innerkits:libbegetutil",
      "//third_party/bounds_checking_function:libsec_static",
    ]

    if (build_selinux) {
      deps += [ "//third_party/selinux:libselinux" ]
      external_deps = [ "selinux:libparaperm_checker" ]
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
X
xionglei6 已提交
157

M
Mupceet 已提交
158
    if (param_test) {
M
Mupceet 已提交
159 160 161 162
      sources += [
        "//base/startup/init_lite/test/moduletest/param_test_cmds.c",
        "//base/startup/init_lite/test/moduletest/syspara.cpp",
      ]
M
Mupceet 已提交
163
      deps += [ "//base/startup/init_lite/interfaces/innerkits:libbeget_proxy" ]
M
Mupceet 已提交
164 165 166 167 168 169 170 171 172 173 174
      defines += [
        "OHOS_SERVICE_DUMP",
        "INIT_TEST",
      ]
    }

    install_images = [ "system" ]
    install_enable = true

    part_name = "init"
  }
M
Mupceet 已提交
175 176 177 178 179 180 181 182 183 184 185 186 187

  ohos_executable("param") {
    sources = [
      "main.c",
      "param_cmd.c",
      "shell/shell_bas.c",
    ]

    defines = [
      "INIT_AGENT",
      "_GNU_SOURCE",
    ]

M
Mupceet 已提交
188
    include_dirs = common_include_dirs
M
Mupceet 已提交
189 190 191
    deps = [
      "//base/startup/init_lite/services/log:agent_log",
      "//base/startup/init_lite/services/loopevent:loopevent",
M
Mupceet 已提交
192 193
      "//base/startup/init_lite/services/param/base:parameterbase",
      "//base/startup/init_lite/services/param/linux:param_client",
M
Mupceet 已提交
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      "//base/startup/init_lite/services/utils:libinit_utils",
      "//third_party/bounds_checking_function:libsec_static",
    ]

    external_deps = [
      "hilog_native:libhilog_base",
      "utils_base:utils",
    ]
    if (build_selinux) {
      deps += [ "//third_party/selinux:libselinux" ]
      external_deps += [ "selinux:libparaperm_checker" ]
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
    install_images = [ "system" ]
    install_enable = true
    part_name = "init"
  }

  group("begetctl_cmd") {
    deps = [
      ":begetctl",
      ":param",
      ":paramshell",
    ]
  }
X
xionglei6 已提交
219
}