1# Copyright (c) 2021-2025 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/hitrace/hitrace.gni") 15import("//build/ohos.gni") 16 17config("libhitrace_pub_config") { 18 visibility = [ ":*" ] 19 20 include_dirs = [ 21 "include", 22 "include/hitrace", 23 ] 24} 25 26ohos_shared_library("libhitracechain") { 27 branch_protector_ret = "pac_ret" 28 public_configs = [ ":libhitrace_pub_config" ] 29 30 deps = [ "$hitrace_frameworks_path/native:hitracechain_source" ] 31 32 cflags = [ "-fstack-protector-strong" ] 33 34 if (defined(ohos_lite)) { 35 external_deps = [ "hilog_lite:hilog_lite" ] 36 } else { 37 external_deps = [ "hilog:libhilog" ] 38 } 39 40 output_extension = "so" 41 install_enable = true 42 43 innerapi_tags = [ 44 "chipsetsdk_sp", 45 "platformsdk", 46 ] 47 48 version_script = "libhitracechain.map" 49 50 install_images = [ 51 "system", 52 "updater", 53 ] 54 55 part_name = "hitrace" 56 subsystem_name = "hiviewdfx" 57} 58 59config("hitrace_meter_config") { 60 visibility = [ ":*" ] 61 include_dirs = [ 62 "include/hitrace_meter", 63 "$hitrace_utils_path", 64 ] 65} 66 67ohos_static_library("hitrace_inner") { 68 branch_protector_ret = "pac_ret" 69 include_dirs = [ 70 "$hitrace_common_path", 71 "include/hitrace_meter", 72 "include", 73 "$hitrace_frameworks_path/include/", 74 "$hitrace_utils_path", 75 ] 76 sources = [ 77 "src/hitrace_meter.cpp", 78 "src/hitrace_meter_c.c", 79 "src/hitrace_meter_wrapper.cpp", 80 ] 81 82 external_deps = [ 83 "bounds_checking_function:libsec_shared", 84 "init:libbeget_proxy", 85 "init:libbegetutil", 86 ] 87 88 if (defined(ohos_lite)) { 89 external_deps += [ "hilog_lite:hilog_lite" ] 90 } else { 91 external_deps += [ "hilog:libhilog" ] 92 } 93 94 if (is_ohos && is_clang && enhanced_opt && hitrace_feature_enable_pgo && 95 (target_cpu == "arm" || target_cpu == "arm64")) { 96 cflags = [ 97 "-fprofile-use=" + 98 rebase_path("${hitrace_feature_pgo_path}/libhitrace_meter.profdata", 99 root_build_dir), 100 "-Wno-error=backend-plugin", 101 "-Wno-profile-instr-out-of-date", 102 "-Wno-profile-instr-unprofiled", 103 ] 104 } 105 106 part_name = "hitrace" 107 subsystem_name = "hiviewdfx" 108} 109 110config("hitrace_dump_config") { 111 visibility = [ ":*" ] 112 include_dirs = [ 113 "include", 114 "$hitrace_common_path", 115 ] 116} 117 118ohos_shared_library("hitrace_dump") { 119 include_dirs = [ 120 "include", 121 "$hitrace_common_path", 122 "$hitrace_cmd_path/include", 123 "$hitrace_frameworks_path/include", 124 "$hitrace_frameworks_path/trace_dump_executor", 125 "$hitrace_frameworks_path/trace_source", 126 "$hitrace_utils_path", 127 ] 128 public_configs = [ ":hitrace_dump_config" ] 129 sources = [ 130 "$hitrace_frameworks_path/native/dynamic_buffer.cpp", 131 "$hitrace_utils_path/file_ageing_utils.cpp", 132 "src/hitrace_dump.cpp", 133 ] 134 135 deps = [ 136 ":hitrace_meter", 137 ":libhitrace_option", 138 "$hitrace_config_path:hitrace_tags", 139 "$hitrace_frameworks_path/trace_dump_executor:trace_dump_executor", 140 "$hitrace_utils_path:hitrace_common_utils", 141 "$hitrace_utils_path:hitrace_file_utils", 142 "$hitrace_utils_path:hitrace_json_parser", 143 ] 144 145 external_deps = [ 146 "bounds_checking_function:libsec_shared", 147 "c_utils:utils", 148 "init:libbegetutil", 149 ] 150 151 if (defined(ohos_lite)) { 152 external_deps += [ "hilog_lite:hilog_lite" ] 153 } else { 154 external_deps += [ "hilog:libhilog" ] 155 } 156 157 cflags_cc = [ "-Os" ] 158 159 ldflags = [ "-Wl,--gc-sections" ] 160 161 version_script = "hitrace.map" 162 innerapi_tags = [ "platformsdk" ] 163 part_name = "hitrace" 164 subsystem_name = "hiviewdfx" 165} 166 167ohos_shared_library("hitrace_meter") { 168 branch_protector_ret = "pac_ret" 169 public_configs = [ ":hitrace_meter_config" ] 170 deps = [ 171 ":hitrace_etc", 172 ":hitrace_inner", 173 ":libhitracechain", 174 "$hitrace_utils_path:hitrace_common_utils", 175 ] 176 177 external_deps = [ "bounds_checking_function:libsec_shared" ] 178 if (defined(ohos_lite)) { 179 external_deps += [ "hilog_lite:hilog_lite" ] 180 } else { 181 external_deps += [ "hilog:libhilog" ] 182 } 183 version_script = "hitrace.map" 184 output_extension = "so" 185 186 innerapi_tags = [ 187 "chipsetsdk_sp", 188 "platformsdk", 189 "sasdk", 190 ] 191 part_name = "hitrace" 192 install_images = [ 193 "system", 194 "updater", 195 ] 196 subsystem_name = "hiviewdfx" 197 198 if (is_ohos && is_clang && enhanced_opt && 199 (target_cpu == "arm64" || target_cpu == "arm")) { 200 ldflags = [ "-Wl,-Bsymbolic" ] 201 if (hitrace_feature_enable_pgo && target_cpu == "arm64" && 202 enable_enhanced_opt) { 203 ldflags += [ "-Wl,--aarch64-inline-plt" ] 204 } 205 } 206} 207 208config("libhitrace_option_config") { 209 visibility = [ ":*" ] 210 211 include_dirs = [ "include" ] 212} 213 214ohos_shared_library("libhitrace_option") { 215 branch_protector_ret = "pac_ret" 216 public_configs = [ ":libhitrace_option_config" ] 217 218 sources = [ "src/hitrace_option/hitrace_option.cpp" ] 219 220 external_deps = [ "init:libbegetutil" ] 221 if (defined(ohos_lite)) { 222 external_deps += [ "hilog_lite:hilog_lite" ] 223 } else { 224 external_deps += [ "hilog:libhilog" ] 225 } 226 227 output_extension = "so" 228 install_enable = true 229 230 innerapi_tags = [ "platformsdk" ] 231 232 version_script = "hitrace.map" 233 234 install_images = [ "system" ] 235 236 part_name = "hitrace" 237 subsystem_name = "hiviewdfx" 238} 239 240ohos_prebuilt_etc("hitrace.para") { 241 source = "hitrace.para" 242 install_images = [ 243 "system", 244 "updater", 245 ] 246 module_install_dir = "etc/param" 247 part_name = "hitrace" 248 subsystem_name = "hiviewdfx" 249} 250 251ohos_prebuilt_etc("hitrace.para.dac") { 252 source = "hitrace.para.dac" 253 install_images = [ 254 "system", 255 "updater", 256 ] 257 module_install_dir = "etc/param" 258 part_name = "hitrace" 259 subsystem_name = "hiviewdfx" 260} 261 262group("hitrace_etc") { 263 deps = [ 264 ":hitrace.para", 265 ":hitrace.para.dac", 266 ] 267} 268