• 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      cflags_cc = [
87        "-std=c++17",
88        "-Wno-deprecated-declarations",
89      ]
90      defines += [ "__MAC__" ]
91    } else if (platform == "linux") {
92      cflags_cc = [ "-std=c++17" ]
93      defines += [ "__LINUX__" ]
94    } else {
95      defines = [ "__RECV_MSG_WITH_UCRED_" ]
96      if (use_musl) {
97        defines += [ "HILOG_USE_MUSL" ]
98      }
99    }
100    cflags = [ "-Wno-deprecated-declarations" ]
101    public_configs = [ ":libhilog_config" ]
102    configs = [ ":libhilog_config" ]
103
104    deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
105
106    if (platform != "windows" && platform != "mac" && platform != "linux") {
107      external_deps = [ "init:libbegetutil" ]
108    }
109
110    part_name = "hilog"
111    subsystem_name = "hiviewdfx"
112  }
113}
114
115foreach(item, platforms) {
116  libhilog_source("libhilog_source_" + item) {
117    platform = item
118  }
119}
120
121config("libhilog_base_config") {
122  visibility = [ "*:*" ]
123  include_dirs = [ "include" ]
124}
125
126ohos_source_set("libhilog_base_source") {
127  include_dirs = [
128    "$vsnprintf_root/include",
129    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
130  ]
131
132  vsnprintf_sources = [ "$vsnprintf_root/vsnprintf_s_p.cpp" ]
133
134  sources = [ "$libhilog_base_root/hilog_base.cpp" ]
135  sources += vsnprintf_sources
136
137  defines = [
138    "__RECV_MSG_WITH_UCRED_",
139    "HILOG_PROHIBIT_ALLOCATION",
140  ]
141  public_configs = [ ":libhilog_base_config" ]
142  configs = [ ":libhilog_base_config" ]
143
144  part_name = "hilog"
145  subsystem_name = "hiviewdfx"
146}
147