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 131# part of default_compiler_configs from build/config/BUILDCONFIG.gn 132musl_inherited_configs_for_musl = [ 133 "//build/config/compiler:afdo", 134 "//build/config/compiler:afdo_optimize_size", 135 "//build/config/compiler:compiler", 136 "//build/config/compiler:compiler_arm_fpu", 137 "//build/config/compiler:compiler_arm_thumb", 138 "//build/config/compiler:chromium_code", 139 "//build/config/compiler:default_include_dirs", 140 "//build/config/compiler:default_optimization", 141 "//build/config/compiler:default_stack_frames", 142 "//build/config/compiler:default_symbols", 143 "//build/config/compiler:export_dynamic", 144 "//build/config/compiler:no_exceptions", 145 "//build/config/compiler:no_rtti", 146 "//build/config/compiler:runtime_library", 147 "//build/config/sanitizers:default_sanitizer_flags", 148] 149 150ohos_static_library("libhilog_base_for_musl") { 151 print("************libhilog_base use_musl ***************") 152 ldflags = [ "-nostdlib" ] 153 remove_configs = musl_inherited_configs_for_musl 154 configs = [ "//build/config/components/musl:soft_musl_config" ] 155 public_configs = [ ":libhilog_base_pub_cfg" ] 156 157 subsystem_name = "hiviewdfx" 158 part_name = "hilog" 159} 160 161ohos_static_library("libhilog_base") { 162 public_configs = [ ":libhilog_base_pub_cfg" ] 163 164 include_dirs = [ 165 "$vsnprintf_root/include", 166 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 167 ] 168 169 vsnprintf_sources = [ 170 "$vsnprintf_root/vsnprintf_s_p.c", 171 "$vsnprintf_root/vsprintf_p.c", 172 ] 173 174 sources = [ "$libhilog_base_root/hilog_base.c" ] 175 sources += vsnprintf_sources 176 defines = [ 177 "__RECV_MSG_WITH_UCRED_", 178 "HILOG_PROHIBIT_ALLOCATION", 179 ] 180 configs = [ ":libhilog_base_config" ] 181 external_deps = [ "bounds_checking_function:libsec_static" ] 182 183 subsystem_name = "hiviewdfx" 184 part_name = "hilog" 185} 186