BUILD.gn 4.8 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
# 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")
import("//build/ohos.gni")

config("exported_header_files") {
  visibility = [ ":*" ]
  include_dirs = [
    "//base/startup/init_lite/interfaces/innerkits/include",
    "//base/startup/init_lite/interfaces/service/include/param",
    "//base/startup/init_lite/interfaces/service/param/include",
  ]
}

param_include_dirs = [
  "//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/init/include",
  "//base/startup/init_lite/services/log",
34
  "//base/startup/init_lite/interfaces/innerkits/init_module_engine/include",
M
Mupceet 已提交
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
  "//base/startup/init_lite/services/loopevent/include",
  "//third_party/bounds_checking_function/include",
  "//third_party/cJSON",
  "//utils/native/lite/include",
  "//base/security/selinux/interfaces/policycoreutils/include",
]

param_service_sources = [
  "//base/startup/init_lite/services/param/adapter/param_persistadp.c",
  "//base/startup/init_lite/services/param/linux/param_message.c",
  "//base/startup/init_lite/services/param/linux/param_msgadp.c",
  "//base/startup/init_lite/services/param/linux/param_service.c",
  "//base/startup/init_lite/services/param/manager/param_manager.c",
  "//base/startup/init_lite/services/param/manager/param_persist.c",
  "//base/startup/init_lite/services/param/manager/param_server.c",
]

param_trigger_sources = [
  "//base/startup/init_lite/services/param/trigger/trigger_checker.c",
  "//base/startup/init_lite/services/param/trigger/trigger_manager.c",
  "//base/startup/init_lite/services/param/trigger/trigger_processor.c",
]

param_client_sources = [
  "//base/startup/init_lite/services/param/linux/param_message.c",
  "//base/startup/init_lite/services/param/linux/param_request.c",
  "//base/startup/init_lite/services/param/manager/param_manager.c",
]

# only for linux
if (defined(ohos_lite)) {
  static_library("param_init") {
    defines = []
    sources = param_service_sources
    sources += param_trigger_sources
    include_dirs = param_include_dirs
    public_configs = [ ":exported_header_files" ]

    if (defined(boot_kernel_extended_cmdline)) {
      defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
    }
    defines += [
      "_GNU_SOURCE",
      "__LINUX__",
79
      "OHOS_LITE",
M
Mupceet 已提交
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
      "INCREMENTAL_VERSION=\"${ohos_version}\"",
      "BUILD_TYPE=\"${ohos_build_type}\"",
      "BUILD_USER=\"${ohos_build_user}\"",
      "BUILD_TIME=\"${ohos_build_time}\"",
      "BUILD_HOST=\"${ohos_build_host}\"",
      "BUILD_ROOTHASH=\"${ohos_build_roothash}\"",
    ]
  }

  static_library("param_client") {
    include_dirs = param_include_dirs
    sources = param_client_sources
    cflags = [ "-fPIC" ]
    public_configs = [ ":exported_header_files" ]
    defines = [
      "_GNU_SOURCE",
      "__LINUX__",
    ]
  }
} else {
  ohos_static_library("param_init") {
    sources = param_service_sources
    sources += param_trigger_sources
    include_dirs = param_include_dirs
    public_configs = [ ":exported_header_files" ]
    defines = [ "_GNU_SOURCE" ]

    if (defined(boot_kernel_extended_cmdline)) {
      defines += [ "BOOT_EXTENDED_CMDLINE=\"${boot_kernel_extended_cmdline}\"" ]
    }

    if (build_selinux) {
M
Mupceet 已提交
112 113 114 115
      include_dirs += [
        "//third_party/selinux/libselinux/include/",
        "//base/security/selinux/interfaces/policycoreutils/include/",
      ]
M
Mupceet 已提交
116 117 118 119 120 121 122 123 124 125
      defines += [ "PARAM_SUPPORT_SELINUX" ]
    }
    part_name = "init"
    subsystem_name = "startup"
  }

  ohos_static_library("param_client") {
    sources = param_client_sources
    include_dirs = param_include_dirs
    public_configs = [ ":exported_header_files" ]
M
Mupceet 已提交
126
    deps = []
M
Mupceet 已提交
127 128 129 130 131
    defines = [
      "_GNU_SOURCE",
      "INIT_AGENT",
    ]
    if (build_selinux) {
M
Mupceet 已提交
132 133 134 135 136
      deps += [
        "//base/security/selinux:libload_policy",
        "//base/security/selinux:librestorecon",
        "//third_party/selinux:libselinux",
      ]
M
Mupceet 已提交
137 138 139 140 141 142 143 144 145
      defines += [
        "PARAM_SUPPORT_SELINUX",
        "PARAMWORKSPACE_NEED_MUTEX",
      ]
    }
    part_name = "init"
    subsystem_name = "startup"
  }
}