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"
19ioctl_root = "$libhilog_root/ioctl"
20param_root = "$libhilog_root/param"
21socket_root = "$libhilog_root/socket"
22utils_root = "$libhilog_root/utils"
23vsnprintf_root = "$libhilog_root/vsnprintf"
24
25config("libhilog_config") {
26  visibility = [ "*:*" ]
27
28  include_dirs = [
29    "include",
30    "$framework_root/include",
31    "$libhilog_root/include",
32    "$ioctl_root/include",
33    "$param_root/include",
34    "$socket_root/include",
35    "$utils_root/include",
36    "$vsnprintf_root/include",
37    "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
38  ]
39}
40
41template("libhilog_source") {
42  forward_variables_from(invoker, "*")
43  ohos_source_set(target_name) {
44    if (platform != "windows" && platform != "mac" && platform != "linux") {
45      param_sources = [ "$param_root/properties.cpp" ]
46      ioctl_sources = [ "$ioctl_root/log_ioctl.cpp" ]
47
48      socket_sources = [
49        "$socket_root/dgram_socket_client.cpp",
50        "$socket_root/dgram_socket_server.cpp",
51        "$socket_root/hilog_input_socket_client.cpp",
52        "$socket_root/hilog_input_socket_server.cpp",
53        "$socket_root/seq_packet_socket_client.cpp",
54        "$socket_root/seq_packet_socket_server.cpp",
55        "$socket_root/socket.cpp",
56        "$socket_root/socket_client.cpp",
57        "$socket_root/socket_server.cpp",
58      ]
59    }
60
61    utils_sources = [
62      "$utils_root/log_print.cpp",
63      "$utils_root/log_utils.cpp",
64    ]
65
66    vsnprintf_sources = [
67      "$vsnprintf_root/vsnprintf_s_p.c",
68      "$vsnprintf_root/vsprintf_p.c",
69    ]
70
71    sources = [
72      "hilog.cpp",
73      "hilog_printf.cpp",
74    ]
75    if (platform != "windows" && platform != "mac" && platform != "linux") {
76      sources += param_sources
77      sources += ioctl_sources
78      sources += socket_sources
79    }
80    sources += utils_sources
81    sources += vsnprintf_sources
82
83    defines = []
84    if (platform == "windows") {
85      cflags_cc = [ "-std=c++17" ]
86      defines += [ "__WINDOWS__" ]
87    } else if (platform == "mac") {
88      cflags_cc = [
89        "-std=c++17",
90        "-Wno-deprecated-declarations",
91      ]
92      defines += [ "__MAC__" ]
93    } else if (platform == "linux") {
94      cflags_cc = [ "-std=c++17" ]
95      defines += [ "__LINUX__" ]
96    } else {
97      defines = [ "__RECV_MSG_WITH_UCRED_" ]
98      if (use_musl) {
99        defines += [ "HILOG_USE_MUSL" ]
100      }
101      if (platform == "ohos") {
102        defines += [ "__OHOS__" ]
103      }
104    }
105    cflags = [ "-Wno-deprecated-declarations" ]
106    public_configs = [ ":libhilog_config" ]
107    configs = [ ":libhilog_config" ]
108
109    external_deps = [ "bounds_checking_function:libsec_shared" ]
110
111    if (platform != "windows" && platform != "mac" && platform != "linux") {
112      external_deps += [ "init:libbegetutil" ]
113    }
114
115    part_name = "hilog"
116    subsystem_name = "hiviewdfx"
117  }
118}
119
120foreach(item, platforms) {
121  libhilog_source("libhilog_source_" + item) {
122    platform = item
123  }
124}
125