• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//base/hiviewdfx/hilog/hilog.gni")
15import("//build/ohos.gni")
16
17framework_root = "//base/hiviewdfx/hilog/frameworks"
18libhilog_root = "$framework_root/libhilog"
19libhilog_base_root = "$libhilog_root/base"
20ioctl_root = "$libhilog_root/ioctl"
21param_root = "$libhilog_root/param"
22socket_root = "$libhilog_root/socket"
23utils_root = "$libhilog_root/utils"
24vsnprintf_root = "$libhilog_root/vsnprintf"
25
26config("libhilog_config") {
27  visibility = [ "*:*" ]
28
29  include_dirs = [
30    "include",
31    "$framework_root/include",
32    "$libhilog_root/include",
33    "$ioctl_root/include",
34    "$param_root/include",
35    "$socket_root/include",
36    "$utils_root/include",
37    "$vsnprintf_root/include",
38    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
39  ]
40}
41
42template("libhilog_source") {
43  forward_variables_from(invoker, "*")
44  ohos_source_set(target_name) {
45    if (platform != "windows" && platform != "mac" && platform != "linux") {
46      param_sources = [ "$param_root/properties.cpp" ]
47      ioctl_sources = [ "$ioctl_root/log_ioctl.cpp" ]
48
49      socket_sources = [
50        "$socket_root/dgram_socket_client.cpp",
51        "$socket_root/dgram_socket_server.cpp",
52        "$socket_root/hilog_input_socket_client.cpp",
53        "$socket_root/hilog_input_socket_server.cpp",
54        "$socket_root/seq_packet_socket_client.cpp",
55        "$socket_root/seq_packet_socket_server.cpp",
56        "$socket_root/socket.cpp",
57        "$socket_root/socket_client.cpp",
58        "$socket_root/socket_server.cpp",
59      ]
60    }
61
62    utils_sources = [
63      "$utils_root/log_print.cpp",
64      "$utils_root/log_utils.cpp",
65    ]
66
67    vsnprintf_sources = [ "$vsnprintf_root/vsnprintf_s_p.cpp" ]
68
69    sources = [
70      "hilog.cpp",
71      "hilog_printf.cpp",
72    ]
73    if (platform != "windows" && platform != "mac" && platform != "linux") {
74      sources += param_sources
75      sources += ioctl_sources
76      sources += socket_sources
77    }
78    sources += utils_sources
79    sources += vsnprintf_sources
80
81    defines = []
82    if (platform == "windows") {
83      cflags_cc = [ "-std=c++17" ]
84      defines += [ "__WINDOWS__" ]
85    } else if (platform == "mac") {
86      defines += [ "__MAC__" ]
87    } else if (platform == "linux") {
88      cflags_cc = [ "-std=c++17" ]
89      defines += [ "__LINUX__" ]
90    } else {
91      defines = [ "__RECV_MSG_WITH_UCRED_" ]
92      if (use_musl) {
93        defines += [ "HILOG_USE_MUSL" ]
94      }
95    }
96    public_configs = [ ":libhilog_config" ]
97    configs = [ ":libhilog_config" ]
98
99    deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
100
101    if (platform != "windows" && platform != "mac" && platform != "linux") {
102      external_deps = [ "init:libbegetutil" ]
103    }
104
105    part_name = "hilog_native"
106    subsystem_name = "hiviewdfx"
107  }
108}
109
110foreach(item, platforms) {
111  libhilog_source("libhilog_source_" + item) {
112    platform = item
113  }
114}
115
116config("libhilog_base_config") {
117  visibility = [ "*:*" ]
118  include_dirs = [ "include" ]
119}
120
121ohos_source_set("libhilog_base_source") {
122  include_dirs = [
123    "$vsnprintf_root/include",
124    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
125  ]
126
127  vsnprintf_sources = [ "$vsnprintf_root/vsnprintf_s_p.cpp" ]
128
129  sources = [ "$libhilog_base_root/hilog_base.cpp" ]
130  sources += vsnprintf_sources
131
132  defines = [
133    "__RECV_MSG_WITH_UCRED_",
134    "HILOG_PROHIBIT_ALLOCATION",
135  ]
136  public_configs = [ ":libhilog_base_config" ]
137  configs = [ ":libhilog_base_config" ]
138
139  part_name = "hilog_native"
140  subsystem_name = "hiviewdfx"
141}
142