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 branch_protector_ret = "pac_ret" 45 sanitize = { 46 cfi = true 47 cfi_cross_dso = true 48 debug = false 49 } 50 if (platform != "windows" && platform != "mac" && platform != "linux") { 51 param_sources = [ "$param_root/properties.cpp" ] 52 ioctl_sources = [ "$ioctl_root/log_ioctl.cpp" ] 53 54 socket_sources = [ 55 "$socket_root/dgram_socket_client.cpp", 56 "$socket_root/dgram_socket_server.cpp", 57 "$socket_root/hilog_input_socket_client.cpp", 58 "$socket_root/hilog_input_socket_server.cpp", 59 "$socket_root/seq_packet_socket_client.cpp", 60 "$socket_root/seq_packet_socket_server.cpp", 61 "$socket_root/socket.cpp", 62 "$socket_root/socket_client.cpp", 63 "$socket_root/socket_server.cpp", 64 ] 65 } 66 67 utils_sources = [ 68 "$utils_root/log_print.cpp", 69 "$utils_root/log_utils.cpp", 70 ] 71 72 vsnprintf_sources = [ 73 "$vsnprintf_root/vsnprintf_s_p.c", 74 "$vsnprintf_root/vsprintf_p.c", 75 ] 76 77 sources = [ 78 "hilog.cpp", 79 "hilog_printf.cpp", 80 ] 81 if (platform != "windows" && platform != "mac" && platform != "linux") { 82 sources += param_sources 83 sources += ioctl_sources 84 sources += socket_sources 85 } 86 sources += utils_sources 87 sources += vsnprintf_sources 88 89 defines = [] 90 if (platform == "windows") { 91 cflags_cc = [ "-std=c++17" ] 92 defines += [ "__WINDOWS__" ] 93 } else if (platform == "mac") { 94 cflags_cc = [ 95 "-std=c++17", 96 "-Wno-deprecated-declarations", 97 ] 98 defines += [ "__MAC__" ] 99 } else if (platform == "linux") { 100 cflags_cc = [ "-std=c++17" ] 101 defines += [ "__LINUX__" ] 102 } else { 103 defines = [ "__RECV_MSG_WITH_UCRED_" ] 104 if (use_musl) { 105 defines += [ "HILOG_USE_MUSL" ] 106 } 107 if (platform == "ohos") { 108 defines += [ "__OHOS__" ] 109 } 110 } 111 cflags = [ "-Wno-deprecated-declarations" ] 112 public_configs = [ ":libhilog_config" ] 113 configs = [ ":libhilog_config" ] 114 115 external_deps = [ "bounds_checking_function:libsec_shared" ] 116 117 if (platform != "windows" && platform != "mac" && platform != "linux") { 118 external_deps += [ "init:libbegetutil" ] 119 } 120 121 part_name = "hilog" 122 subsystem_name = "hiviewdfx" 123 } 124} 125 126foreach(item, platforms) { 127 libhilog_source("libhilog_source_" + item) { 128 platform = item 129 } 130} 131