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 = [ "$vsnprintf_root/vsnprintf_s_p.c" ] 67 68 sources = [ 69 "hilog.cpp", 70 "hilog_printf.cpp", 71 ] 72 if (platform != "windows" && platform != "mac" && platform != "linux") { 73 sources += param_sources 74 sources += ioctl_sources 75 sources += socket_sources 76 } 77 sources += utils_sources 78 sources += vsnprintf_sources 79 80 defines = [] 81 if (platform == "windows") { 82 cflags_cc = [ "-std=c++17" ] 83 defines += [ "__WINDOWS__" ] 84 } else if (platform == "mac") { 85 cflags_cc = [ 86 "-std=c++17", 87 "-Wno-deprecated-declarations", 88 ] 89 defines += [ "__MAC__" ] 90 } else if (platform == "linux") { 91 cflags_cc = [ "-std=c++17" ] 92 defines += [ "__LINUX__" ] 93 } else { 94 defines = [ "__RECV_MSG_WITH_UCRED_" ] 95 if (use_musl) { 96 defines += [ "HILOG_USE_MUSL" ] 97 } 98 if (platform == "ohos") { 99 defines += [ "__OHOS__" ] 100 } 101 } 102 cflags = [ "-Wno-deprecated-declarations" ] 103 public_configs = [ ":libhilog_config" ] 104 configs = [ ":libhilog_config" ] 105 106 external_deps = [ "bounds_checking_function:libsec_shared" ] 107 108 if (platform != "windows" && platform != "mac" && platform != "linux") { 109 external_deps += [ "init:libbegetutil" ] 110 } 111 112 part_name = "hilog" 113 subsystem_name = "hiviewdfx" 114 } 115} 116 117foreach(item, platforms) { 118 libhilog_source("libhilog_source_" + item) { 119 platform = item 120 } 121} 122