# Copyright (C) 2024 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("../../gn/test.gni")

# The main entry point for external processes. This is separate from
# "trace_redaction" because tests also depend on "trace_redaction".
executable("trace_redactor") {
  sources = [ "main.cc" ]
  deps = [
    ":trace_redaction",
    "../../gn:default_deps",
    "../base",
  ]
}

source_set("trace_redaction") {
  sources = [
    "add_synth_threads_to_process_trees.cc",
    "add_synth_threads_to_process_trees.h",
    "broadphase_packet_filter.cc",
    "broadphase_packet_filter.h",
    "collect_clocks.cc",
    "collect_clocks.h",
    "collect_frame_cookies.cc",
    "collect_frame_cookies.h",
    "collect_system_info.cc",
    "collect_system_info.h",
    "collect_timeline_events.cc",
    "collect_timeline_events.h",
    "drop_empty_ftrace_events.cc",
    "drop_empty_ftrace_events.h",
    "filtering.cc",
    "filtering.h",
    "find_package_uid.cc",
    "find_package_uid.h",
    "frame_cookie.h",
    "merge_threads.cc",
    "merge_threads.h",
    "modify.cc",
    "modify.h",
    "populate_allow_lists.cc",
    "populate_allow_lists.h",
    "process_thread_timeline.cc",
    "process_thread_timeline.h",
    "proto_util.cc",
    "proto_util.h",
    "prune_package_list.cc",
    "prune_package_list.h",
    "prune_perf_events.cc",
    "prune_perf_events.h",
    "redact_ftrace_events.cc",
    "redact_ftrace_events.h",
    "redact_process_events.cc",
    "redact_process_events.h",
    "redact_sched_events.cc",
    "redact_sched_events.h",
    "redactor_clock_converter.cc",
    "redactor_clock_converter.h",
    "reduce_threads_in_process_trees.cc",
    "reduce_threads_in_process_trees.h",
    "scrub_process_stats.cc",
    "scrub_process_stats.h",
    "trace_redaction_framework.cc",
    "trace_redaction_framework.h",
    "trace_redactor.cc",
    "trace_redactor.h",
    "verify_integrity.cc",
    "verify_integrity.h",
  ]
  deps = [
    "../../gn:default_deps",
    "../../include/perfetto/protozero:protozero",
    "../../include/perfetto/trace_processor:util",
    "../../protos/perfetto/common:zero",
    "../../protos/perfetto/trace:minimal_zero",
    "../../protos/perfetto/trace:non_minimal_zero",
    "../../protos/perfetto/trace/android:zero",
    "../../protos/perfetto/trace/ftrace:zero",
    "../../protos/perfetto/trace/profiling:zero",
    "../../protos/perfetto/trace/ps:zero",
    "../base",
    "../trace_processor/util:blob",
    "../trace_processor/util:clock",
  ]
}

source_set("integrationtests") {
  testonly = true
  sources = [
    "boardphase_packet_filter_integrationtest.cc",
    "collect_frame_cookies_integrationtest.cc",
    "filter_sched_waking_events_integrationtest.cc",
    "filter_task_rename_integrationtest.cc",
    "process_thread_timeline_integrationtest.cc",
    "prune_package_list_integrationtest.cc",
    "prune_perf_events_integrationtest.cc",
    "redact_sched_events_integrationtest.cc",
    "reduce_threads_in_process_trees_integrationtest.cc",
    "scrub_process_stats_integrationtest.cc",
    "trace_processor_integrationtest.cc",
    "trace_redaction_integration_fixture.cc",
    "trace_redaction_integration_fixture.h",
  ]
  deps = [
    ":trace_redaction",
    "../../gn:default_deps",
    "../../gn:gtest_and_gmock",
    "../../include/perfetto/trace_processor:trace_processor",
    "../../protos/perfetto/trace:non_minimal_cpp",
    "../../protos/perfetto/trace:non_minimal_zero",
    "../../protos/perfetto/trace/android:cpp",
    "../../protos/perfetto/trace/android:zero",
    "../../protos/perfetto/trace/ftrace:zero",
    "../../protos/perfetto/trace/ps:zero",
    "../base",
    "../base:test_support",
  ]
}

perfetto_unittest_source_set("unittests") {
  testonly = true
  sources = [
    "broadphase_packet_filter_unittest.cc",
    "collect_clocks_unittest.cc",
    "collect_frame_cookies_unittest.cc",
    "collect_system_info_unittest.cc",
    "collect_timeline_events_unittest.cc",
    "filter_sched_waking_events_unittest.cc",
    "find_package_uid_unittest.cc",
    "process_thread_timeline_unittest.cc",
    "proto_util_unittest.cc",
    "prune_package_list_unittest.cc",
    "redact_process_events_unittest.cc",
    "redact_sched_events_unittest.cc",
    "verify_integrity_unittest.cc",
  ]
  deps = [
    ":trace_redaction",
    "../../gn:default_deps",
    "../../gn:gtest_and_gmock",
    "../../include/perfetto/protozero:protozero",
    "../../protos/perfetto/common:cpp",
    "../../protos/perfetto/common:zero",
    "../../protos/perfetto/config:cpp",
    "../../protos/perfetto/config:zero",
    "../../protos/perfetto/trace:minimal_cpp",
    "../../protos/perfetto/trace:non_minimal_cpp",
    "../../protos/perfetto/trace:zero",
    "../../protos/perfetto/trace/android:cpp",
    "../../protos/perfetto/trace/android:zero",
    "../../protos/perfetto/trace/ftrace:cpp",
    "../../protos/perfetto/trace/ftrace:zero",
    "../../protos/perfetto/trace/ps:cpp",
    "../../protos/perfetto/trace/ps:zero",
    "../base",
    "../base:test_support",
  ]
}
