1# Copyright (C) 2018 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("../../../gn/perfetto.gni") 16import("../../../gn/test.gni") 17 18sql_files = [ 19 "trace_metadata.sql", 20 "trace_stats.sql", 21 "android/android_batt.sql", 22 "android/android_cpu.sql", 23 "android/android_surfaceflinger.sql", 24 "android/android_cpu_agg.sql", 25 "android/android_cpu_raw_metrics_per_core.sql", 26 "android/android_dma_heap.sql", 27 "android/android_fastrpc.sql", 28 "android/android_gpu.sql", 29 "android/android_hwui_threads.sql", 30 "android/android_mem.sql", 31 "android/android_mem_unagg.sql", 32 "android/android_ion.sql", 33 "android/composer_execution.sql", 34 "android/composition_layers.sql", 35 "android/frame_missed.sql", 36 "android/android_jank.sql", 37 "android/android_lmk_reason.sql", 38 "android/android_lmk.sql", 39 "android/android_powrails.sql", 40 "android/android_proxy_power.sql", 41 "android/android_startup_launches.sql", 42 "android/android_startup.sql", 43 "android/android_package_list.sql", 44 "android/android_task_names.sql", 45 "android/android_thread_time_in_state.sql", 46 "android/cpu_info.sql", 47 "android/display_metrics.sql", 48 "android/g2d.sql", 49 "android/g2d_duration.sql", 50 "android/hsc_startups.sql", 51 "android/android_hwcomposer.sql", 52 "android/android_hwui_metric.sql", 53 "android/java_heap_histogram.sql", 54 "android/java_heap_stats.sql", 55 "android/power_drain_in_watts.sql", 56 "android/power_profile_data.sql", 57 "android/process_unagg_mem_view.sql", 58 "android/process_mem.sql", 59 "android/process_metadata.sql", 60 "android/process_oom_score.sql", 61 "android/mem_stats_priority_breakdown.sql", 62 "android/span_view_stats.sql", 63 "android/android_sysui_cuj.sql", 64 "android/process_counter_span_view.sql", 65 "android/global_counter_span_view.sql", 66 "android/unsymbolized_frames.sql", 67 "chrome/actual_power_by_category.sql", 68 "chrome/actual_power_by_rail_mode.sql", 69 "chrome/chrome_event_metadata.sql", 70 "chrome/chrome_processes.sql", 71 "chrome/chrome_thread_slice_with_cpu_time.sql", 72 "chrome/cpu_time_by_category.sql", 73 "chrome/cpu_time_by_rail_mode.sql", 74 "chrome/estimated_power_by_category.sql", 75 "chrome/estimated_power_by_rail_mode.sql", 76 "chrome/rail_modes.sql", 77 "chrome/scroll_jank.sql", 78 "chrome/scroll_jank_cause.sql", 79 "chrome/scroll_jank_cause_blocking_task.sql", 80 "chrome/scroll_jank_cause_blocking_touch_move.sql", 81 "chrome/scroll_jank_cause_get_bitmap.sql", 82 "chrome/scroll_jank_cause_queuing_delay.sql", 83 "chrome/scroll_flow_event.sql", 84 "chrome/scroll_flow_event_queuing_delay.sql", 85 "chrome/test_chrome_metric.sql", 86 "experimental/blink_gc_metric.sql", 87 "experimental/frame_times.sql", 88 "experimental/media_metric.sql", 89 "experimental/reported_by_page.sql", 90 "webview/webview_power_usage.sql", 91] 92 93config("gen_config") { 94 include_dirs = [ "${root_gen_dir}/${perfetto_root_path}" ] 95} 96 97action("gen_merged_sql_metrics") { 98 script = "../../../tools/gen_merged_sql_metrics.py" 99 generated_header = "${target_gen_dir}/sql_metrics.h" 100 args = rebase_path(sql_files, root_build_dir) + [ 101 "--cpp_out", 102 rebase_path(generated_header, root_build_dir), 103 ] 104 inputs = sql_files 105 outputs = [ generated_header ] 106 public_configs = [ ":gen_config" ] 107} 108 109action("gen_cc_metrics_descriptor") { 110 descriptor_target = "../../../protos/perfetto/metrics:descriptor" 111 generated_header = "${target_gen_dir}/metrics.descriptor.h" 112 113 descriptor_file_path = get_label_info(descriptor_target, "target_gen_dir") + 114 "/metrics.descriptor" 115 116 script = "../../../tools/gen_cc_proto_descriptor.py" 117 deps = [ descriptor_target ] 118 args = [ 119 "--gen_dir", 120 rebase_path(root_gen_dir, root_build_dir), 121 "--cpp_out", 122 rebase_path(generated_header, root_build_dir), 123 rebase_path(descriptor_file_path, root_build_dir), 124 ] 125 inputs = [ descriptor_file_path ] 126 outputs = [ generated_header ] 127 public_configs = [ ":gen_config" ] 128} 129 130action("gen_cc_all_chrome_metrics_descriptor") { 131 descriptor_target = "../../../protos/perfetto/metrics/chrome:descriptor" 132 generated_header = "${target_gen_dir}/chrome/all_chrome_metrics.descriptor.h" 133 134 descriptor_file_path = get_label_info(descriptor_target, "target_gen_dir") + 135 "/all_chrome_metrics.descriptor" 136 137 script = "../../../tools/gen_cc_proto_descriptor.py" 138 deps = [ descriptor_target ] 139 args = [ 140 "--gen_dir", 141 rebase_path(root_gen_dir, root_build_dir), 142 "--cpp_out", 143 rebase_path(generated_header, root_build_dir), 144 rebase_path(descriptor_file_path, root_build_dir), 145 ] 146 inputs = [ descriptor_file_path ] 147 outputs = [ generated_header ] 148 public_configs = [ ":gen_config" ] 149} 150 151if (enable_perfetto_trace_processor_sqlite) { 152 source_set("lib") { 153 sources = [ 154 "metrics.cc", 155 "metrics.h", 156 ] 157 deps = [ 158 "..:metatrace", 159 "../../../gn:default_deps", 160 "../../../gn:sqlite", 161 "../../../include/perfetto/trace_processor", 162 "../../../protos/perfetto/common:zero", 163 "../../../protos/perfetto/trace_processor:metrics_impl_zero", 164 "../../base", 165 "../../protozero:protozero", 166 "../sqlite", 167 ] 168 public_deps = [ 169 ":gen_cc_all_chrome_metrics_descriptor", 170 ":gen_cc_metrics_descriptor", 171 ":gen_merged_sql_metrics", 172 "../util", 173 "../util:descriptors", 174 ] 175 } 176 177 perfetto_unittest_source_set("unittests") { 178 testonly = true 179 sources = [ "metrics_unittest.cc" ] 180 deps = [ 181 ":lib", 182 "..:lib", 183 "../../../gn:default_deps", 184 "../../../gn:gtest_and_gmock", 185 "../../../gn:sqlite", 186 "../../../protos/perfetto/common:zero", 187 ] 188 } 189} 190