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" 20vsnprintf_root = "$libhilog_root/vsnprintf" 21 22config("libhilog_pub_config") { 23 visibility = [ ":*" ] 24 include_dirs = [ "include" ] 25} 26if (is_mingw || is_mac || is_linux || is_ohos) { 27 ohos_shared_library("libhilog") { 28 public_configs = [ ":libhilog_pub_config" ] 29 if (is_ohos) { 30 deps = [ "../../../frameworks/libhilog:libhilog_source_ohos" ] 31 } else if (is_mingw) { 32 deps = [ "../../../frameworks/libhilog:libhilog_source_windows" ] 33 } else if (is_mac) { 34 deps = [ "../../../frameworks/libhilog:libhilog_source_mac" ] 35 } else if (is_linux) { 36 deps = [ "../../../frameworks/libhilog:libhilog_source_linux" ] 37 } 38 39 if (is_ohos) { 40 output_extension = "so" 41 version_script = "libhilog.map" 42 innerapi_tags = [ 43 "chipsetsdk", 44 "platformsdk", 45 "sasdk", 46 ] 47 install_enable = !hilog_native_feature_ohcore 48 install_images = [ 49 "system", 50 "updater", 51 ] 52 sanitize = { 53 cfi = true 54 cfi_cross_dso = true 55 debug = false 56 } 57 } 58 59 part_name = "hilog" 60 subsystem_name = "hiviewdfx" 61 } 62} 63 64template("libhilog") { 65 forward_variables_from(invoker, "*") 66 if (current_os == "android" || current_os == "ios") { 67 ohos_static_library(target_name) { 68 public_configs = [ ":libhilog_pub_config" ] 69 deps = [ "../../../platform:libhilog_platform_source_$platform" ] 70 71 part_name = "hilog" 72 subsystem_name = "hiviewdfx" 73 } 74 } else { 75 ohos_shared_library(target_name) { 76 sanitize = { 77 cfi = true 78 cfi_cross_dso = true 79 debug = false 80 } 81 public_configs = [ ":libhilog_pub_config" ] 82 deps = [ "../../../frameworks/libhilog:libhilog_source_$platform" ] 83 if (platform == "ohos") { 84 output_extension = "so" 85 version_script = "libhilog.map" 86 } 87 88 install_enable = !hilog_native_feature_ohcore 89 install_images = [ 90 "system", 91 "updater", 92 ] 93 94 if (platform == "ohos") { 95 innerapi_tags = [ 96 "chipsetsdk", 97 "platformsdk", 98 "sasdk", 99 ] 100 } 101 102 part_name = "hilog" 103 subsystem_name = "hiviewdfx" 104 } 105 } 106} 107 108foreach(item, platforms) { 109 if (item == "windows" || item == "mac" || item == "linux" || item == "ios" || 110 item == "android") { 111 libhilog("libhilog_" + item) { 112 platform = item 113 } 114 } 115} 116 117config("libhilog_base_pub_cfg") { 118 visibility = [ "*:*" ] 119 include_dirs = [ 120 "include", 121 "../../../frameworks/libhilog/include", 122 "../../../frameworks/libhilog/vsnprintf/include", 123 ] 124} 125 126config("libhilog_base_config") { 127 visibility = [ "*:*" ] 128 include_dirs = [ "../../../frameworks/libhilog/include" ] 129} 130 131ohos_static_library("libhilog_base") { 132 public_configs = [ ":libhilog_base_pub_cfg" ] 133 134 include_dirs = [ 135 "$vsnprintf_root/include", 136 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 137 ] 138 139 vsnprintf_sources = [ "$vsnprintf_root/vsnprintf_s_p.c" ] 140 141 sources = [ "$libhilog_base_root/hilog_base.c" ] 142 sources += vsnprintf_sources 143 defines = [ 144 "__RECV_MSG_WITH_UCRED_", 145 "HILOG_PROHIBIT_ALLOCATION", 146 ] 147 configs = [ ":libhilog_base_config" ] 148 149 subsystem_name = "hiviewdfx" 150 part_name = "hilog" 151} 152