1# Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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("//build/ohos.gni")
15import("../../../build/ts.gni")
16config("ebpf_parser_cfg") {
17  if (!is_independent_compile) {
18    configs = [ "${TS_DIR}/gn:ts_config" ]
19  }
20  include_dirs = [
21    ".",
22    "../",
23    "../..",
24    "../../trace_data",
25    "../../base",
26    "../../include",
27    "../../filter",
28    "../../cfg",
29    "../../trace_streamer",
30    "../../proto_reader/include",
31    "${THIRD_PARTY}/protobuf/src",
32    "${THIRD_PARTY}/sqlite/include",
33    "${THIRD_PARTY}/bounds_checking_function/include",
34  ]
35  include_dirs += [
36    "${SRC}/trace_data/trace_stdtype",
37    "${SRC}/trace_data/trace_stdtype/ftrace",
38    "${SRC}/trace_data/trace_stdtype/ftrace/template",
39    "${SRC}/trace_data/trace_stdtype/hilog",
40    "${SRC}/trace_data/trace_stdtype/hiperf",
41    "${SRC}/trace_data/trace_stdtype/hisysevent",
42    "${SRC}/trace_data/trace_stdtype/htrace",
43    "${SRC}/trace_data/trace_stdtype/measure",
44  ]
45  if (is_mingw || is_mac) {
46    include_dirs += [ "${THIRD_PARTY}/elfutils/libelf" ]
47  }
48  if (enable_ts_utest && !use_wasm) {
49    cflags = [
50      "-fprofile-arcs",
51      "-ftest-coverage",
52    ]
53    ldflags = [
54      "-fprofile-arcs",
55      "-ftest-coverage",
56      "--coverage",
57    ]
58    if (is_test) {
59      cflags += [ "-D IS_UT" ]
60    }
61  }
62}
63
64ohos_static_library("ebpf_parser") {
65  subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
66  part_name = "${OHOS_PROFILER_PART_NAME}"
67  sources = [
68    "bio_latency_data_parser.cpp",
69    "ebpf_base.cpp",
70    "ebpf_data_parser.cpp",
71    "ebpf_data_reader.cpp",
72    "ebpf_splitter.cpp",
73    "file_system_data_parser.cpp",
74    "paged_memory_data_parser.cpp",
75  ]
76  public_configs = [ ":ebpf_parser_cfg" ]
77  public_deps = [
78    "${OHOS_TRACE_STREAMER_PROTOS_DIR}/protos/types/plugins/memory_data:memory_data_reader",
79    "${PERF_DIR}/hiperf:hiperf_src",
80  ]
81  deps = [
82    "${THIRD_PARTY}/protobuf:protobuf_lite_static",
83    "${THIRD_PARTY}/protobuf:protobuf_static",
84  ]
85}
86