BUILD.gn 6.1 KB
Newer Older
Z
zhong_ning 已提交
1
# Copyright (c) 2021 Huawei Device Co., Ltd.
Z
zhong_ning 已提交
2 3 4 5 6 7 8 9 10 11 12
# 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.
13
import("//base/startup/init_lite/begetd.gni")
Z
zhong_ning 已提交
14

M
Mupceet 已提交
15 16 17 18 19 20
param_comm_sources = [
  "adapter/param_dac.c",
  "manager/param_manager.c",
  "manager/param_trie.c",
  "manager/param_utils.c",
]
S
sun_fan 已提交
21

M
Mupceet 已提交
22 23
if (!defined(ohos_lite) || ohos_kernel_type == "linux") {
  param_service_sources = [
M
Mupceet 已提交
24
    "adapter/param_persistadp.c",
M
Mupceet 已提交
25
    "linux/param_message.c",
M
Mupceet 已提交
26 27
    "linux/param_msgadp.c",
    "linux/param_osadp.c",
M
Mupceet 已提交
28 29 30 31 32
    "linux/param_service.c",
    "manager/param_persist.c",
  ]

  param_trigger_sources = [
Z
zhong_ning 已提交
33 34 35 36
    "trigger/trigger_checker.c",
    "trigger/trigger_manager.c",
    "trigger/trigger_processor.c",
  ]
M
Mupceet 已提交
37
}
Z
zhong_ning 已提交
38

M
Mupceet 已提交
39 40 41 42
action("lite_const_param_to") {
  script = "//base/startup/init_lite/scripts/param_cfg_to_code.py"
  args = [
    "--source",
M
Mupceet 已提交
43 44
    rebase_path(
        "//base/startup/init_lite/services/etc/param/ohos_const/ohos.para"),
M
Mupceet 已提交
45 46
    "--dest_dir",
    rebase_path("$root_out_dir/gen/init_lite/"),
M
Mupceet 已提交
47 48
    "--priority",
    "0",
Z
zhong_ning 已提交
49
  ]
M
Mupceet 已提交
50 51
  outputs = [ "$target_gen_dir/${target_name}_param_cfg_to_code.log" ]
}
Z
zhong_ning 已提交
52

M
Mupceet 已提交
53 54 55 56 57 58 59
action("lite_ohos_param_to") {
  script = "//base/startup/init_lite/scripts/param_cfg_to_code.py"
  args = [
    "--source",
    rebase_path("//base/startup/init_lite/services/etc/param/ohos.para"),
    "--dest_dir",
    rebase_path("$root_out_dir/gen/init_lite/"),
M
Mupceet 已提交
60 61
    "--priority",
    "0",
M
Mupceet 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
  ]
  outputs = [ "$target_gen_dir/${target_name}_param_cfg_to_code.log" ]
}

param_include_dirs = [
  "include",
  "adapter",
  "linux",
  "//base/startup/init_lite/services/include/param",
  "//base/startup/init_lite/services/include",
  "//base/startup/init_lite/services/init/include",
  "//base/startup/init_lite/services/log",
  "//base/startup/init_lite/interfaces/innerkits/include",
  "//base/startup/init_lite/services/loopevent/include",
  "//base/security/selinux/interfaces/policycoreutils/include",
  "//third_party/libuv/include",
  "//third_party/bounds_checking_function/include",
  "//third_party/cJSON",
]
S
sun_fan 已提交
81

M
Mupceet 已提交
82 83 84 85 86 87 88 89 90
if (defined(ohos_lite)) {
  static_library("param_init") {
    defines = []
    deps = []
    sources = param_comm_sources
    include_dirs = param_include_dirs
    if (defined(boot_kernel_extended_cmdline)) {
      defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
    }
M
Mupceet 已提交
91
    defines += [ "_GNU_SOURCE" ]
M
Mupceet 已提交
92 93 94
    if (ohos_kernel_type == "linux") {
      sources += param_service_sources
      sources += param_trigger_sources
M
Mupceet 已提交
95
      defines += [ "__LINUX__" ]
M
Mupceet 已提交
96 97 98 99
    } else if (ohos_kernel_type == "liteos_a") {
      sources += [
        "adapter/param_persistadp.c",
        "liteos/param_osadp.c",
M
Mupceet 已提交
100 101
        "liteos/param_service.c",
        "manager/param_persist.c",
M
Mupceet 已提交
102 103 104 105 106 107
      ]
      defines += [
        "WORKSPACE_AREA_NEED_MUTEX",
        "PARAM_PERSIST_SAVE_MUTEX",
        "PARAMWORKSPACE_NEED_MUTEX",
        "__LITEOS_A__",
M
Mupceet 已提交
108
        "PARAM_SUPPORT_CYCLE_CHECK",
M
Mupceet 已提交
109 110 111
      ]
      deps += [
        ":lite_const_param_to",
M
Mupceet 已提交
112
        ":lite_ohos_param_to",
M
Mupceet 已提交
113 114 115 116
      ]
      include_dirs += [ "$root_out_dir/gen/init_lite" ]
      defines += [ "PARAM_LOAD_CFG_FROM_CODE" ]
    }
117 118
  }

M
Mupceet 已提交
119 120 121 122 123 124 125 126
  static_library("param_client") {
    sources = param_comm_sources
    include_dirs = param_include_dirs
    defines = [ "_GNU_SOURCE" ]
    if (ohos_kernel_type == "linux") {
      sources += [
        "linux/param_message.c",
        "linux/param_osadp.c",
M
Mupceet 已提交
127
        "linux/param_request.c",
M
Mupceet 已提交
128
      ]
M
Mupceet 已提交
129
      defines += [ "__LINUX__" ]
M
Mupceet 已提交
130 131 132 133 134
    } else if (ohos_kernel_type == "liteos_a") {
      sources += [
        "adapter/param_persistadp.c",
        "liteos/param_client.c",
        "liteos/param_osadp.c",
M
Mupceet 已提交
135
        "manager/param_persist.c",
M
Mupceet 已提交
136 137 138 139 140 141 142 143 144 145 146 147
      ]
      defines += [
        "__LITEOS_A__",
        "WORKSPACE_AREA_NEED_MUTEX",
        "PARAM_PERSIST_SAVE_MUTEX",
        "PARAMWORKSPACE_NEED_MUTEX",
      ]
    } else if (ohos_kernel_type == "liteos_m") {
      sources += [
        "adapter/param_persistadp.c",
        "liteos/param_client.c",
        "liteos/param_osadp.c",
M
Mupceet 已提交
148
        "manager/param_persist.c",
M
Mupceet 已提交
149 150 151 152 153 154 155 156 157 158
      ]
      defines += [
        "__LITEOS_M__",
        "WORKSPACE_AREA_NEED_MUTEX",
        "PARAM_PERSIST_SAVE_MUTEX",
        "PARAMWORKSPACE_NEED_MUTEX",
        "DATA_PATH=\"${config_ohos_startup_init_lite_data_path}\"",
      ]
      deps = [
        ":lite_const_param_to",
M
Mupceet 已提交
159
        ":lite_ohos_param_to",
M
Mupceet 已提交
160 161 162
      ]
      include_dirs += [ "$root_out_dir/gen/init_lite" ]
      defines += [ "PARAM_LOAD_CFG_FROM_CODE" ]
X
x00405909 已提交
163
    }
S
sun_fan 已提交
164
  }
M
Mupceet 已提交
165 166
} else {
  import("//build/ohos.gni")
S
sun_fan 已提交
167

M
Mupceet 已提交
168 169 170 171 172
  ohos_static_library("param_init") {
    sources = param_comm_sources
    sources += param_service_sources
    sources += param_trigger_sources
    include_dirs = param_include_dirs
Z
zhong_ning 已提交
173

M
Mupceet 已提交
174
    defines = [ "_GNU_SOURCE" ]
Z
zhong_ning 已提交
175

M
Mupceet 已提交
176 177 178
    if (defined(boot_kernel_extended_cmdline)) {
      defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
    }
Z
zhong_ning 已提交
179

M
Mupceet 已提交
180 181 182 183
    if (build_selinux) {
      sources += [ "adapter/param_selinux.c" ]
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
S
sun_fan 已提交
184

M
Mupceet 已提交
185 186 187 188 189 190 191 192
    deps = [
      "//base/startup/init_lite/services/log:init_log",
      "//base/startup/init_lite/services/loopevent:loopevent",
      "//base/startup/init_lite/services/utils:libinit_tools",
      "//base/startup/init_lite/services/utils:libinit_utils",
    ]
    part_name = "init"
    subsystem_name = "startup"
X
xionglei6 已提交
193 194
  }

M
Mupceet 已提交
195 196 197 198 199
  ohos_static_library("param_client") {
    sources = param_comm_sources
    sources += [
      "linux/param_message.c",
      "linux/param_osadp.c",
M
Mupceet 已提交
200
      "linux/param_request.c",
M
Mupceet 已提交
201 202
    ]
    include_dirs = param_include_dirs
S
sun_fan 已提交
203

M
Mupceet 已提交
204 205 206 207 208
    defines = [ "_GNU_SOURCE" ]
    if (build_selinux) {
      sources += [ "adapter/param_selinux.c" ]
      defines += [
        "PARAM_SUPPORT_SELINUX",
M
Mupceet 已提交
209
        "PARAMWORKSPACE_NEED_MUTEX",
M
Mupceet 已提交
210 211 212
      ]
    }
    part_name = "init"
T
taiyipei 已提交
213
  }
Z
zhong_ning 已提交
214
}