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} 26 27group("libhilog_host") { 28 deps = [ ":libhilog($host_toolchain)" ] 29} 30 31if (is_mingw || is_mac || is_linux || is_ohos) { 32 ohos_shared_library("libhilog") { 33 public_configs = [ ":libhilog_pub_config" ] 34 if (is_ohos) { 35 deps = [ "../../../frameworks/libhilog:libhilog_source_ohos" ] 36 } else if (is_mingw) { 37 deps = [ "../../../frameworks/libhilog:libhilog_source_windows" ] 38 } else if (is_mac) { 39 deps = [ "../../../frameworks/libhilog:libhilog_source_mac" ] 40 } else if (is_linux) { 41 deps = [ "../../../frameworks/libhilog:libhilog_source_linux" ] 42 } 43 44 if (is_ohos) { 45 output_extension = "so" 46 version_script = "libhilog.map" 47 innerapi_tags = [ 48 "chipsetsdk", 49 "platformsdk", 50 "sasdk", 51 ] 52 install_enable = !hilog_native_feature_ohcore 53 install_images = [ 54 "system", 55 "updater", 56 ] 57 branch_protector_ret = "pac_ret" 58 sanitize = { 59 cfi = true 60 cfi_cross_dso = true 61 debug = false 62 } 63 } 64 65 part_name = "hilog" 66 subsystem_name = "hiviewdfx" 67 } 68} 69 70template("libhilog") { 71 forward_variables_from(invoker, "*") 72 if (current_os == "android" || current_os == "ios") { 73 ohos_static_library(target_name) { 74 public_configs = [ ":libhilog_pub_config" ] 75 deps = [ "../../../platform:libhilog_platform_source_$platform" ] 76 77 part_name = "hilog" 78 subsystem_name = "hiviewdfx" 79 } 80 } else { 81 ohos_shared_library(target_name) { 82 branch_protector_ret = "pac_ret" 83 sanitize = { 84 cfi = true 85 cfi_cross_dso = true 86 debug = false 87 } 88 public_configs = [ ":libhilog_pub_config" ] 89 deps = [ "../../../frameworks/libhilog:libhilog_source_$platform" ] 90 if (platform == "ohos") { 91 output_extension = "so" 92 version_script = "libhilog.map" 93 } 94 95 install_enable = !hilog_native_feature_ohcore 96 install_images = [ 97 "system", 98 "updater", 99 ] 100 101 if (platform == "ohos") { 102 innerapi_tags = [ 103 "chipsetsdk", 104 "platformsdk", 105 "sasdk", 106 ] 107 } 108 109 part_name = "hilog" 110 subsystem_name = "hiviewdfx" 111 } 112 } 113} 114 115foreach(item, platforms) { 116 if (item == "windows" || item == "mac" || item == "linux" || item == "ios" || 117 item == "android") { 118 libhilog("libhilog_" + item) { 119 platform = item 120 } 121 } 122} 123 124config("libhilog_base_pub_cfg") { 125 visibility = [ "*:*" ] 126 include_dirs = [ 127 "include", 128 "../../../frameworks/libhilog/include", 129 "../../../frameworks/libhilog/vsnprintf/include", 130 ] 131} 132 133config("libhilog_base_config") { 134 visibility = [ "*:*" ] 135 include_dirs = [ "../../../frameworks/libhilog/include" ] 136} 137 138# part of default_compiler_configs from build/config/BUILDCONFIG.gn 139musl_inherited_configs_for_musl = [ 140 "//build/config/compiler:afdo", 141 "//build/config/compiler:afdo_optimize_size", 142 "//build/config/compiler:compiler", 143 "//build/config/compiler:compiler_arm_fpu", 144 "//build/config/compiler:compiler_arm_thumb", 145 "//build/config/compiler:chromium_code", 146 "//build/config/compiler:default_include_dirs", 147 "//build/config/compiler:default_optimization", 148 "//build/config/compiler:default_stack_frames", 149 "//build/config/compiler:default_symbols", 150 "//build/config/compiler:export_dynamic", 151 "//build/config/compiler:no_exceptions", 152 "//build/config/compiler:no_rtti", 153 "//build/config/compiler:runtime_library", 154 "//build/config/sanitizers:default_sanitizer_flags", 155] 156 157ohos_static_library("libhilog_base_for_musl") { 158 print("************libhilog_base use_musl ***************") 159 ldflags = [ "-nostdlib" ] 160 remove_configs = musl_inherited_configs_for_musl 161 configs = [ "//build/config/components/musl:soft_musl_config" ] 162 public_configs = [ ":libhilog_base_pub_cfg" ] 163 164 subsystem_name = "hiviewdfx" 165 part_name = "hilog" 166} 167 168ohos_static_library("libhilog_base") { 169 public_configs = [ ":libhilog_base_pub_cfg" ] 170 171 include_dirs = [ 172 "$vsnprintf_root/include", 173 "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", 174 ] 175 176 vsnprintf_sources = [ 177 "$vsnprintf_root/vsnprintf_s_p.c", 178 "$vsnprintf_root/vsprintf_p.c", 179 ] 180 181 sources = [ "$libhilog_base_root/hilog_base.c" ] 182 sources += vsnprintf_sources 183 defines = [ 184 "__RECV_MSG_WITH_UCRED_", 185 "HILOG_PROHIBIT_ALLOCATION", 186 ] 187 configs = [ ":libhilog_base_config" ] 188 external_deps = [ "bounds_checking_function:libsec_static" ] 189 190 subsystem_name = "hiviewdfx" 191 part_name = "hilog" 192} 193