#!/usr/bin/env python
# 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.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import re
import sys
from codecs import open

COMMON_PROTOS = (
    'protos/perfetto/common/android_log_constants.proto',
    'protos/perfetto/common/data_source_descriptor.proto',
    'protos/perfetto/common/gpu_counter_descriptor.proto',
    'protos/perfetto/common/sys_stats_counters.proto',
    'protos/perfetto/common/trace_stats.proto',
    'protos/perfetto/common/tracing_service_state.proto',
    'protos/perfetto/common/track_event_descriptor.proto',
)

CONFIG_PROTOS = (
    'protos/perfetto/config/android/android_log_config.proto',
    'protos/perfetto/config/chrome/chrome_config.proto',
    'protos/perfetto/config/data_source_config.proto',
    'protos/perfetto/config/ftrace/ftrace_config.proto',
    'protos/perfetto/config/inode_file/inode_file_config.proto',
    'protos/perfetto/config/power/android_power_config.proto',
    'protos/perfetto/config/process_stats/process_stats_config.proto',
    'protos/perfetto/config/sys_stats/sys_stats_config.proto',
    'protos/perfetto/config/test_config.proto',
    'protos/perfetto/config/trace_config.proto',
    'protos/perfetto/config/profiling/heapprofd_config.proto',
    'protos/perfetto/config/profiling/java_hprof_config.proto',
    'protos/perfetto/config/profiling/perf_event_config.proto',
    'protos/perfetto/config/gpu/gpu_counter_config.proto',
    'protos/perfetto/config/gpu/vulkan_memory_config.proto',
    'protos/perfetto/config/android/packages_list_config.proto',
)

MERGED_CONFIG_PROTO = 'protos/perfetto/config/perfetto_config.proto'

TRACE_PROTOS = (
    'protos/perfetto/trace/android/android_log.proto',
    'protos/perfetto/trace/android/graphics_frame_event.proto',
    'protos/perfetto/trace/android/packages_list.proto',
    'protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto',
    "protos/perfetto/trace/chrome/chrome_metadata.proto",
    'protos/perfetto/trace/clock_snapshot.proto',
    'protos/perfetto/trace/filesystem/inode_file_map.proto',
    'protos/perfetto/trace/ftrace/binder.proto',
    'protos/perfetto/trace/ftrace/block.proto',
    'protos/perfetto/trace/ftrace/clk.proto',
    'protos/perfetto/trace/ftrace/ext4.proto',
    'protos/perfetto/trace/ftrace/f2fs.proto',
    'protos/perfetto/trace/ftrace/filemap.proto',
    'protos/perfetto/trace/ftrace/ftrace.proto',
    'protos/perfetto/trace/ftrace/ftrace_event.proto',
    'protos/perfetto/trace/ftrace/ftrace_event_bundle.proto',
    'protos/perfetto/trace/ftrace/ftrace_stats.proto',
    'protos/perfetto/trace/ftrace/generic.proto',
    'protos/perfetto/trace/ftrace/kmem.proto',
    'protos/perfetto/trace/ftrace/lowmemorykiller.proto',
    'protos/perfetto/trace/ftrace/mm_event.proto',
    'protos/perfetto/trace/ftrace/power.proto',
    'protos/perfetto/trace/ftrace/raw_syscalls.proto',
    'protos/perfetto/trace/ftrace/sched.proto',
    'protos/perfetto/trace/ftrace/signal.proto',
    'protos/perfetto/trace/ftrace/systrace.proto',
    'protos/perfetto/trace/ftrace/task.proto',
    'protos/perfetto/trace/ftrace/vmscan.proto',
    'protos/perfetto/trace/interned_data/interned_data.proto',
    'protos/perfetto/trace/perfetto/perfetto_metatrace.proto',
    'protos/perfetto/trace/power/battery_counters.proto',
    'protos/perfetto/trace/power/power_rails.proto',
    'protos/perfetto/trace/profiling/heap_graph.proto',
    'protos/perfetto/trace/profiling/profile_common.proto',
    'protos/perfetto/trace/profiling/profile_packet.proto',
    'protos/perfetto/trace/ps/process_stats.proto',
    'protos/perfetto/trace/ps/process_tree.proto',
    'protos/perfetto/trace/sys_stats/sys_stats.proto',
    'protos/perfetto/trace/system_info.proto',
    'protos/perfetto/trace/trace.proto',
    'protos/perfetto/trace/trace_packet.proto',
    'protos/perfetto/trace/trace_packet_defaults.proto',
    'protos/perfetto/trace/track_event/chrome_compositor_scheduler_state.proto',
    'protos/perfetto/trace/track_event/chrome_histogram_sample.proto',
    'protos/perfetto/trace/track_event/chrome_keyed_service.proto',
    'protos/perfetto/trace/track_event/chrome_legacy_ipc.proto',
    'protos/perfetto/trace/track_event/chrome_process_descriptor.proto',
    'protos/perfetto/trace/track_event/chrome_thread_descriptor.proto',
    'protos/perfetto/trace/track_event/chrome_user_event.proto',
    'protos/perfetto/trace/track_event/debug_annotation.proto',
    'protos/perfetto/trace/track_event/log_message.proto',
    'protos/perfetto/trace/track_event/process_descriptor.proto',
    'protos/perfetto/trace/track_event/source_location.proto',
    'protos/perfetto/trace/track_event/task_execution.proto',
    'protos/perfetto/trace/track_event/thread_descriptor.proto',
    'protos/perfetto/trace/track_event/track_descriptor.proto',
    'protos/perfetto/trace/track_event/track_event.proto',
    'protos/perfetto/trace/trigger.proto',
    'protos/perfetto/trace/gpu/gpu_counter_event.proto',
    'protos/perfetto/trace/gpu/gpu_log.proto',
    'protos/perfetto/trace/gpu/gpu_render_stage_event.proto',
    'protos/perfetto/trace/gpu/vulkan_api_event.proto',
)

MERGED_TRACE_PROTO = 'protos/perfetto/trace/perfetto_trace.proto'

METRICS_PROTOS = (
    'protos/perfetto/metrics/metrics.proto',
)

MERGED_METRICS_PROTO = 'protos/perfetto/metrics/perfetto_merged_metrics.proto'

REPLACEMENT_HEADER = '''
// AUTOGENERATED - DO NOT EDIT
// ---------------------------
// This file has been generated by
// AOSP://external/perfetto/%s
// merging the perfetto config protos.
// This fused proto is intended to be copied in:
//  - Android tree, for statsd.
//  - Google internal repos.

syntax = "proto2";

package perfetto.protos;
'''


def merge_protos_content(proto_paths, follow_imports, added_files, add_header):
  root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
  merged_content = ''
  for proto in proto_paths:
    if proto in added_files:
      continue
    added_files.add(proto)

    path = os.path.join(root_dir, proto)
    with open(path, 'r', encoding='utf-8') as f:
      content = f.read()

    # Remove header
    header = re.match(r'\/(\*|\/)(?:.|\s)*?package .*;\n', content)
    header = header.group(0)
    content = content[len(header):]
    if merged_content == '' and add_header:
      merged_content += REPLACEMENT_HEADER.lstrip() % __file__

    if follow_imports:
      matches = re.findall(r'^import "(.*)";\n\n?', content, flags=re.MULTILINE)
      merged_content += merge_protos_content(
          matches, follow_imports, added_files, add_header=False)

    content = re.sub(r'^import.*?\n\n?', '', content, flags=re.MULTILINE)
    merged_content += '\n// Begin of %s\n' % proto
    merged_content += content
    merged_content += '\n// End of %s\n' % proto

  definitions_re = r'^ *(?:message|enum) ([A-Z][A-Za-z0-9].*) {'
  definitions = re.finditer(definitions_re, merged_content, re.MULTILINE)
  types = set((match.group(1) for match in definitions))

  uses_re = r'^( +)(?:repeated)?(?:optional)?\s'\
            r'?([A-Z]\w+.*)\s+[a-z]\w+\s*=\s*(\d+);'
  uses = re.finditer(uses_re, merged_content, re.MULTILINE)
  substitutions = []
  for use in uses:
    everything = use.group(0)
    indentation = use.group(1)
    used_type = use.group(2)
    field_number = use.group(3)
    if used_type not in types:
      replacement = '{}// removed field with id {}'.format(
          indentation, field_number)
      substitutions.append((everything, replacement))

  for before, after in substitutions:
    merged_content = merged_content.replace(before, after)

  return merged_content


def merge_protos(proto_paths, output_path, follow_imports):
  root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
  merged_content = merge_protos_content(
      proto_paths, follow_imports, added_files=set(), add_header=True)
  out_path = os.path.join(root_dir, output_path)

  prev_content = None
  if os.path.exists(out_path):
    with open(out_path, 'r', encoding='utf-8') as fprev:
      prev_content = fprev.read()

  if prev_content == merged_content:
    return True

  if '--check-only' in sys.argv:
    return False

  print('Updating {}'.format(output_path))
  with open(out_path, 'w', encoding='utf-8') as fout:
    fout.write(merged_content)
  return True


def main():
  result = merge_protos(COMMON_PROTOS + CONFIG_PROTOS, MERGED_CONFIG_PROTO,
                        False)
  result &= merge_protos(COMMON_PROTOS + TRACE_PROTOS + CONFIG_PROTOS,
                         MERGED_TRACE_PROTO, False)
  result &= merge_protos(METRICS_PROTOS, MERGED_METRICS_PROTO, True)
  return 0 if result else 1


if __name__ == '__main__':
  sys.exit(main())
