# Copyright (C) 2018 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/proto_library.gni")

perfetto_proto_library("@TYPE@") {
  deps = [
    ":winscope_regular_@TYPE@",
    "../../common:@TYPE@",
  ]

  sources = [
    "android_game_intervention_list.proto",
    "android_log.proto",
    "android_system_property.proto",
    "app_wakelock_data.proto",
    "bluetooth_trace.proto",
    "camera_event.proto",
    "cpu_per_uid_data.proto",
    "frame_timeline_event.proto",
    "gpu_mem_event.proto",
    "graphics_frame_event.proto",
    "initial_display_state.proto",
    "kernel_wakelock_data.proto",
    "network_trace.proto",
    "packages_list.proto",
    "pixel_modem_events.proto",
    "user_list.proto",
  ]
}

perfetto_proto_library("winscope_common_@TYPE@") {
  sources = [
    "graphics/insets.proto",
    "graphics/point.proto",
    "graphics/rect.proto",
    "winscope_extensions.proto",
  ]
}

# Winscope messages added to TracePacket directly
perfetto_proto_library("winscope_regular_@TYPE@") {
  deps = [
    ":winscope_common_@TYPE@",
    "../../common:@TYPE@",
  ]
  sources = [
    "protolog.proto",
    "shell_transition.proto",
    "surfaceflinger_common.proto",
    "surfaceflinger_layers.proto",
    "surfaceflinger_transactions.proto",
  ]
}

# Winscope messages added to TracePacket as extensions
perfetto_proto_library("winscope_extensions_@TYPE@") {
  proto_generators = [ "zero" ]
  public_deps = [ ":winscope_common_@TYPE@" ]
  sources = [
    "android_input_event.proto",
    "app/statusbarmanager.proto",
    "app/window_configuration.proto",
    "content/activityinfo.proto",
    "content/configuration.proto",
    "content/locale.proto",
    "graphics/pixelformat.proto",
    "inputmethodeditor.proto",
    "inputmethodservice/inputmethodservice.proto",
    "inputmethodservice/softinputwindow.proto",
    "privacy.proto",
    "server/animationadapter.proto",
    "server/inputmethod/inputmethodmanagerservice.proto",
    "server/surfaceanimator.proto",
    "server/windowcontainerthumbnail.proto",
    "server/windowmanagerservice.proto",
    "typedef.proto",
    "view/display.proto",
    "view/displaycutout.proto",
    "view/displayinfo.proto",
    "view/enums.proto",
    "view/imefocuscontroller.proto",
    "view/imeinsetssourceconsumer.proto",
    "view/inputmethod/editorinfo.proto",
    "view/inputmethod/inputconnection.proto",
    "view/inputmethod/inputmethodmanager.proto",
    "view/insetsanimationcontrolimpl.proto",
    "view/insetscontroller.proto",
    "view/insetssource.proto",
    "view/insetssourceconsumer.proto",
    "view/insetssourcecontrol.proto",
    "view/insetsstate.proto",
    "view/remote_animation_target.proto",
    "view/surface.proto",
    "view/surfacecontrol.proto",
    "view/viewrootimpl.proto",
    "view/windowlayoutparams.proto",
    "viewcapture.proto",
    "windowmanager.proto",
    "winscope_extensions_impl.proto",
  ]
  import_dirs = [ "${perfetto_protobuf_src_dir}" ]
}

static_library("perfetto_winscope_extensions_zero") {
  complete_static_lib = true
  deps = [ ":winscope_extensions_zero" ]
}

perfetto_proto_library("winscope_@TYPE@") {
  proto_generators = []
  sources = [ "winscope.proto" ]
  deps = [
    ":winscope_extensions_@TYPE@",
    ":winscope_regular_@TYPE@",
  ]
  import_dirs = [ "${perfetto_protobuf_src_dir}" ]
  generate_descriptor = "winscope.descriptor"
  generator_visibility = [ "../../../../src/trace_processor/importers/proto/winscope:gen_cc_winscope_descriptor" ]
  descriptor_root_source = "winscope.proto"
}

# Android track_event extensions
perfetto_proto_library("android_track_event_@TYPE@") {
  sources = [ "android_track_event.proto" ]
  public_deps = [ "../track_event:@TYPE@" ]
  generator_visibility = [ "../../../../src/trace_processor/importers/proto:gen_cc_android_track_event_descriptor" ]
  generate_descriptor = "android_track_event.descriptor"
  descriptor_root_source = "android_track_event.proto"

  # This is the descriptor for an extension. It shouldn't include the descriptor
  # for the base message as well.
  exclude_imports = true
}
